public Map ( TestContextResultAggregate results, bool includeAllCheckpoints = false, System.TimeSpan aggregationTimeSpan = null ) : IEnumerable |
||
results | Viki.LoadRunner.Engine.Aggregators.Aggregates.TestContextResultAggregate | |
includeAllCheckpoints | bool | |
aggregationTimeSpan | System.TimeSpan | |
Результат | IEnumerable |
public IEnumerable<ResultItemRow> Map(TestContextResultAggregate results, bool includeAllCheckpoints = false, TimeSpan? aggregationTimeSpan = null)
{
IEnumerable<string> resultsOrder = _orderLearner.LearnedOrder;
List<CheckpointAggregate> orderedResults =
resultsOrder
.Where(results.CheckpointAggregates.ContainsKey)
.Select(checkpointName => results.CheckpointAggregates[checkpointName]).ToList();
if (includeAllCheckpoints)
yield return
new ResultItemRow(results, results.CheckpointAggregates[Checkpoint.IterationSetupCheckpointName], aggregationTimeSpan);
int iterationCount = 0;
if (results.CheckpointAggregates.ContainsKey(Checkpoint.IterationEndCheckpointName))
{
foreach (CheckpointAggregate resultItem in orderedResults.GetRange(2, orderedResults.Count - 3))
{
var resultItemRow = new ResultItemRow(results, resultItem, aggregationTimeSpan);
resultItemRow.SetErrors(orderedResults[1 + iterationCount].Errors);
iterationCount++;
yield return resultItemRow;
}
}
else if (
results.CheckpointAggregates.ContainsKey(Checkpoint.IterationStartCheckpointName)
&& results.CheckpointAggregates.ContainsKey(Checkpoint.IterationEndCheckpointName) == false
)
{
foreach (CheckpointAggregate resultItem in orderedResults.GetRange(2, orderedResults.Count - 3))
{
var resultItemRow = new ResultItemRow(results, resultItem, aggregationTimeSpan);
resultItemRow.SetErrors(orderedResults[1 + iterationCount].Errors);
iterationCount++;
yield return resultItemRow;
}
ResultItemRow iterationEndRow = new ResultItemRow(
Checkpoint.IterationEndCheckpointName,
new ResultItemRow(results, orderedResults[orderedResults.Count - 2])
)
{
Count = 0,
SuccessIterationsPerSec = 0
};
yield return iterationEndRow;
}
if (includeAllCheckpoints)
yield return
new ResultItemRow(results, results.CheckpointAggregates[Checkpoint.IterationTearDownCheckpointName]);
}
/// <summary> /// Build results object from aggregated data /// </summary> /// <returns>Aggregated results</returns> public IEnumerable<HistogramResultRow> GetResults() { if (_orderLearner.LearnedOrder.Count != 0) { TimeSpan lastAggregationBeginMark = TimeSpan.MinValue; if (AggregationTimePeriod != null) { TimeSpan lastIterationBeginMark = _histogramItems.Max(h => h.Value.IterationBeginTime); lastAggregationBeginMark = TimeSpan.FromTicks( (lastIterationBeginMark.Ticks / AggregationTimePeriod.Value.Ticks) * AggregationTimePeriod.Value.Ticks ); } ResultsMapper mapper = new ResultsMapper(_orderLearner); foreach (KeyValuePair<object, TestContextResultAggregate> histogramItem in _histogramItems) { HistogramResultRow result = new HistogramResultRow( histogramItem.Key, histogramItem.Value, mapper.Map(histogramItem.Value, true, histogramItem.Value.IterationBeginTime >= lastAggregationBeginMark ? null : AggregationTimePeriod).ToList() ); yield return result; } } }