@Test public void testGetRPSForSecond() { System.out.println("getRPSForSecond"); long sec = 0L; VariableThroughputTimer instance = new VariableThroughputTimer(); int expResult = -1; double result = instance.getRPSForSecond(sec).getLeft(); assertEquals(expResult, result, 0.01); }
public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) { JMeterProperty data = getData(); if (data instanceof NullProperty) { return Pair.of(-1.0, 0L); } CollectionProperty rows = (CollectionProperty) data; PropertyIterator scheduleIT = rows.iterator(); double newSec = elapsedSinceStartOfTestSec; double result = -1; boolean resultComputed = false; long totalDuration = 0; while (scheduleIT.hasNext()) { @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue(); int duration = getIntValue(curProp, DURATION_FIELD_NO); totalDuration += duration; if (!resultComputed) { double fromRps = getDoubleValue(curProp, FROM_FIELD_NO); double toRps = getDoubleValue(curProp, TO_FIELD_NO); if (newSec - duration <= 0) { result = fromRps + newSec * (toRps - fromRps) / (double) duration; resultComputed = true; } else { newSec -= duration; } } } return Pair.of(result, totalDuration); }
VariableThroughputTimer extends AbstractTestElement implements Timer, NoThreadClone, TestStateListener { public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) { JMeterProperty data = getData(); if (data instanceof NullProperty) { return Pair.of(-1.0, 0L); } CollectionProperty rows = (CollectionProperty) data; PropertyIterator scheduleIT = rows.iterator(); double newSec = elapsedSinceStartOfTestSec; double result = -1; boolean resultComputed = false; long totalDuration = 0; while (scheduleIT.hasNext()) { @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue(); int duration = getIntValue(curProp, DURATION_FIELD_NO); totalDuration += duration; if (!resultComputed) { double fromRps = getDoubleValue(curProp, FROM_FIELD_NO); double toRps = getDoubleValue(curProp, TO_FIELD_NO); if (newSec - duration <= 0) { result = fromRps + newSec * (toRps - fromRps) / (double) duration; resultComputed = true; } else { newSec -= duration; } } } return Pair.of(result, totalDuration); } }
VariableThroughputTimer extends AbstractTestElement implements Timer, NoThreadClone, TestStateListener { public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) { JMeterProperty data = getData(); if (data instanceof NullProperty) { return Pair.of(-1.0, 0L); } CollectionProperty rows = (CollectionProperty) data; PropertyIterator scheduleIT = rows.iterator(); double newSec = elapsedSinceStartOfTestSec; double result = -1; boolean resultComputed = false; long totalDuration = 0; while (scheduleIT.hasNext()) { @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue(); int duration = getIntValue(curProp, DURATION_FIELD_NO); totalDuration += duration; if (!resultComputed) { double fromRps = getDoubleValue(curProp, FROM_FIELD_NO); double toRps = getDoubleValue(curProp, TO_FIELD_NO); if (newSec - duration <= 0) { result = fromRps + newSec * (toRps - fromRps) / (double) duration; resultComputed = true; } else { newSec -= duration; } } } return Pair.of(result, totalDuration); } VariableThroughputTimer(); }
VariableThroughputTimer extends AbstractTestElement implements Timer, NoThreadClone, TestStateListener { public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) { JMeterProperty data = getData(); if (data instanceof NullProperty) { return Pair.of(-1.0, 0L); } CollectionProperty rows = (CollectionProperty) data; PropertyIterator scheduleIT = rows.iterator(); double newSec = elapsedSinceStartOfTestSec; double result = -1; boolean resultComputed = false; long totalDuration = 0; while (scheduleIT.hasNext()) { @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue(); int duration = getIntValue(curProp, DURATION_FIELD_NO); totalDuration += duration; if (!resultComputed) { double fromRps = getDoubleValue(curProp, FROM_FIELD_NO); double toRps = getDoubleValue(curProp, TO_FIELD_NO); if (newSec - duration <= 0) { result = fromRps + newSec * (toRps - fromRps) / (double) duration; resultComputed = true; } else { newSec -= duration; } } } return Pair.of(result, totalDuration); } VariableThroughputTimer(); synchronized long delay(); void setData(CollectionProperty rows); JMeterProperty getData(); Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec); @Override void testStarted(); @Override void testStarted(String string); @Override void testEnded(); @Override void testEnded(String string); }
VariableThroughputTimer extends AbstractTestElement implements Timer, NoThreadClone, TestStateListener { public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) { JMeterProperty data = getData(); if (data instanceof NullProperty) { return Pair.of(-1.0, 0L); } CollectionProperty rows = (CollectionProperty) data; PropertyIterator scheduleIT = rows.iterator(); double newSec = elapsedSinceStartOfTestSec; double result = -1; boolean resultComputed = false; long totalDuration = 0; while (scheduleIT.hasNext()) { @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue(); int duration = getIntValue(curProp, DURATION_FIELD_NO); totalDuration += duration; if (!resultComputed) { double fromRps = getDoubleValue(curProp, FROM_FIELD_NO); double toRps = getDoubleValue(curProp, TO_FIELD_NO); if (newSec - duration <= 0) { result = fromRps + newSec * (toRps - fromRps) / (double) duration; resultComputed = true; } else { newSec -= duration; } } } return Pair.of(result, totalDuration); } VariableThroughputTimer(); synchronized long delay(); void setData(CollectionProperty rows); JMeterProperty getData(); Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec); @Override void testStarted(); @Override void testStarted(String string); @Override void testEnded(); @Override void testEnded(String string); static final String DATA_PROPERTY; static final int DURATION_FIELD_NO; static final int FROM_FIELD_NO; static final int TO_FIELD_NO; }