コード例 #1
0
ファイル: TextUI.java プロジェクト: cgore/grinder-code
  /**
   * Constructor.
   *
   * @param translations Translation service.
   * @param processControl Console process control.
   * @param sampleModel Console sample model.
   * @param logger Logger.
   */
  public TextUI(
      final Translations translations,
      final ProcessControl processControl,
      final SampleModel sampleModel,
      final Logger logger) {

    m_logger = logger;
    m_logger.info(GrinderBuild.getName());

    m_shutdownHook = new Thread(new ShutdownHook(translations));
    Runtime.getRuntime().addShutdownHook(m_shutdownHook);

    m_errorHandler = new ErrorHandlerImplementation();

    processControl.addProcessStatusListener(new ProcessListener(translations));

    m_sampleModel = sampleModel;
    m_sampleModel.addModelListener(
        new SampleModel.AbstractListener() {
          @Override
          public void stateChanged() {
            m_logger.info(m_sampleModel.getState().getDescription());
          }
        });
  }
コード例 #2
0
ファイル: SingleConsole.java プロジェクト: qz267/ngrinder
  /*
   * (non-Javadoc)
   *
   * @see
   * net.grinder.console.model.SampleListener#update(net.grinder.statistics
   * .StatisticsSet, net.grinder.statistics.StatisticsSet)
   */
  @Override
  public void update(
      final StatisticsSet intervalStatistics, final StatisticsSet cumulativeStatistics) {
    try {
      if (!capture) {
        return;
      }
      samplingCount++;
      long currentPeriod = cumulativeStatistics.getValue(getSampleModel().getPeriodIndex());
      setTpsValue(sampleModel.getTPSExpression().getDoubleValue(intervalStatistics));
      checkTooLowTps(getTpsValues());
      updateStatistics(intervalStatistics, cumulativeStatistics);

      writeIntervalCsvData(intervalStatistics);
      int interval = getSampleModel().getSampleInterval();
      long gap = 1;
      if (samplingCount == 1) {
        lastSamplingPeriod = currentPeriod;
      } else {
        lastSamplingPeriod = lastSamplingPeriod + interval;
        gap = ((currentPeriod - lastSamplingPeriod) / interval);
      }
      // Adjust sampling delay.. run write data multiple times... when it
      // takes longer than 1
      // sec.

      samplingLifeCycleListener.apply(
          new Informer<SamplingLifeCycleListener>() {
            @Override
            public void inform(SamplingLifeCycleListener listener) {
              listener.onSampling(getReportPath(), intervalStatistics, cumulativeStatistics);
            }
          });
      for (int i = 0; i < (gap + 1); i++) {
        final boolean lastCall = (samplingCount == 1 && i == 0) || (samplingCount != 1 && i == gap);
        writeIntervalSummaryData(intervalStatistics, lastCall);
        if (interval >= (MIN_SAMPLING_INTERVAL_TO_ACTIVATE_TPS_PER_TEST)) {
          writeIntervalSummaryDataPerTest(intervalStatisticMapPerTest, lastCall);
        }
        samplingLifeCycleFollowupListener.apply(
            new Informer<SamplingLifeCycleFollowUpListener>() {
              @Override
              public void inform(SamplingLifeCycleFollowUpListener listener) {
                listener.onSampling(
                    getReportPath(), intervalStatistics, cumulativeStatistics, lastCall);
              }
            });
      }
      checkTooManyError(cumulativeStatistics);
      lastSamplingPeriod = lastSamplingPeriod + (interval * gap);
    } catch (RuntimeException e) {
      LOGGER.error("Error occurred while updating the statistics : {}", e.getMessage());
      LOGGER.debug("Details : ", e);
      throw e;
    }
  }