All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.core.steps.StopwatchEndStep Maven / Gradle / Ivy

There is a newer version: 0.27.1
Show newest version
package io.hyperfoil.core.steps;

import io.hyperfoil.api.session.Access;
import io.hyperfoil.api.session.Session;
import io.hyperfoil.api.statistics.Statistics;
import io.hyperfoil.core.session.SessionFactory;

public class StopwatchEndStep extends StatisticsStep {
   private final Access key;
   private final String metrics;

   public StopwatchEndStep(Object key, String metrics) {
      super(StatisticsStep.nextId());
      this.key = SessionFactory.access(key);
      this.metrics = metrics;
   }

   @Override
   public boolean invoke(Session session) {
      long now = System.nanoTime();
      StopwatchBeginStep.StartTime startTime = (StopwatchBeginStep.StartTime) key.getObject(session);
      Statistics statistics = session.statistics(id(), metrics);
      statistics.incrementRequests(startTime.timestampMillis);
      statistics.recordResponse(startTime.timestampMillis, 0, now - startTime.timestampNanos);
      // TODO: record any request/response counts?
      return true;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy