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.config.Sequence;
import io.hyperfoil.api.session.Access;
import io.hyperfoil.api.session.Session;
import io.hyperfoil.api.statistics.Statistics;
import io.hyperfoil.core.session.SessionFactory;
import io.hyperfoil.function.SerializableSupplier;

public class StopwatchEndStep extends BaseStep {
   private final Access key;

   public StopwatchEndStep(SerializableSupplier sequence, Object key) {
      super(sequence);
      this.key = SessionFactory.access(key);
   }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy