/** * Build up statistics for current sampling. * * @param accumulatedStatistics intervalStatistics * @param intervalStatistics cumulatedStatistics */ protected void updateStatistics( StatisticsSet intervalStatistics, StatisticsSet accumulatedStatistics) { Map<String, Object> result = newHashMap(); result.put("testTime", getCurrentRunningTime() / 1000); List<Map<String, Object>> cumulativeStatistics = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> lastSampleStatistics = new ArrayList<Map<String, Object>>(); for (Test test : accumulatedStatisticMapPerTest.keySet()) { Map<String, Object> accumulatedStatisticMap = newHashMap(); Map<String, Object> intervalStatisticsMap = newHashMap(); StatisticsSet accumulatedSet = this.accumulatedStatisticMapPerTest.get(test); StatisticsSet intervalSet = this.intervalStatisticMapPerTest.get(test); accumulatedStatisticMap.put("testNumber", test.getNumber()); accumulatedStatisticMap.put("testDescription", test.getDescription()); intervalStatisticsMap.put("testNumber", test.getNumber()); intervalStatisticsMap.put("testDescription", test.getDescription()); // When only 1 test is running, it's better to use the parameterized // snapshot. for (Entry<String, StatisticExpression> each : getExpressionEntrySet()) { if (INTERESTING_STATISTICS.contains(each.getKey())) { accumulatedStatisticMap.put( each.getKey(), getRealDoubleValue(each.getValue().getDoubleValue(accumulatedSet))); intervalStatisticsMap.put( each.getKey(), getRealDoubleValue(each.getValue().getDoubleValue(intervalSet))); } } cumulativeStatistics.add(accumulatedStatisticMap); lastSampleStatistics.add(intervalStatisticsMap); } Map<String, Object> totalStatistics = newHashMap(); for (Entry<String, StatisticExpression> each : getExpressionEntrySet()) { if (INTERESTING_STATISTICS.contains(each.getKey())) { totalStatistics.put( each.getKey(), getRealDoubleValue(each.getValue().getDoubleValue(accumulatedStatistics))); } } result.put("totalStatistics", totalStatistics); result.put("cumulativeStatistics", cumulativeStatistics); result.put("lastSampleStatistics", lastSampleStatistics); result.put("tpsChartData", getTpsValues()); result.put("peakTpsForGraph", this.peakTpsForGraph); synchronized (this) { result.put(GrinderConstants.P_PROCESS, this.runningProcess); result.put(GrinderConstants.P_THREAD, this.runningThread); result.put("success", !isAllTestFinished()); } // Finally overwrite.. current one. this.statisticData = result; }
TestData( ThreadContextLocator threadContextLocator, StatisticsSetFactory statisticsSetFactory, TestStatisticsHelper testStatisticsHelper, TimeAuthority timeAuthority, Instrumenter instrumenter, Test testDefinition) { m_statisticsSetFactory = statisticsSetFactory; m_testStatisticsHelper = testStatisticsHelper; m_timeAuthority = timeAuthority; m_instrumenter = instrumenter; m_threadContextLocator = threadContextLocator; m_test = testDefinition; m_testStatistics = m_statisticsSetFactory.create(); m_logMarker = MarkerFactory.getMarker("test-" + testDefinition.getNumber()); }