@Test public void testScheduleThread() { System.out.println("scheduleThread"); HashTree hashtree = new HashTree(); hashtree.add(new LoopController()); JMeterThread thread = new JMeterThread(hashtree, null, null); SteppingThreadGroup instance = new SteppingThreadGroup(); instance.setNumThreads(15); instance.setInUserCount("5"); instance.setInUserCountBurst("10"); instance.setInUserPeriod("30"); instance.setRampUp("10"); instance.setThreadGroupDelay("5"); instance.setFlightTime("60"); long s1 = -1, s2; for (int n = 0; n < 10; n++) { thread.setThreadNum(n); instance.scheduleThread(thread); s2 = thread.getStartTime(); if (s1 >= 0) { assertEquals(1000, s2 - s1); } s1 = s2; } thread.setThreadNum(10); instance.scheduleThread(thread); s2 = thread.getStartTime(); assertEquals(31000, s2 - s1); s1 = s2; for (int n = 11; n < 15; n++) { thread.setThreadNum(n); instance.scheduleThread(thread); s2 = thread.getStartTime(); if (s1 >= 0) { assertEquals(2000, s2 - s1); } s1 = s2; } }
@Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { int inUserCount = getInUserCountAsInt(); int outUserCount = getOutUserCountAsInt(); if (inUserCount == 0) { inUserCount = getNumThreads(); } if (outUserCount == 0) { outUserCount = getNumThreads(); } int inUserCountBurst = Math.min(getInUserCountBurstAsInt(), getNumThreads()); if (inUserCountBurst <= 0) { inUserCountBurst = inUserCount; } int rampUpBucket = thread.getThreadNum() < inUserCountBurst ? 0 : 1 + (thread.getThreadNum() - inUserCountBurst) / inUserCount; int rampUpBucketThreadCount = thread.getThreadNum() < inUserCountBurst ? inUserCountBurst : inUserCount; long threadGroupDelay = 1000L * getThreadGroupDelayAsInt(); long ascentPoint = tgStartTime + threadGroupDelay; long inUserPeriod = 1000L * getInUserPeriodAsInt(); long additionalRampUp = 1000L * getRampUpAsInt() / rampUpBucketThreadCount; long flightTime = 1000L * getFlightTimeAsInt(); long outUserPeriod = 1000L * getOutUserPeriodAsInt(); long rampUpDuration = 1000L * getRampUpAsInt(); long iterationDuration = inUserPeriod + rampUpDuration; int iterationCountTotal = getNumThreads() < inUserCountBurst ? 1 : (int) Math.ceil((double) (getNumThreads() - inUserCountBurst) / inUserCount); int lastIterationUserCount = (getNumThreads() - inUserCountBurst) % inUserCount; if (lastIterationUserCount == 0) { lastIterationUserCount = inUserCount; } long descentPoint = ascentPoint + iterationCountTotal * iterationDuration + (1000L * getRampUpAsInt() / inUserCount) * lastIterationUserCount + flightTime; long rampUpBucketStartTime = ascentPoint + rampUpBucket * iterationDuration; int rampUpBucketThreadPosition = thread.getThreadNum() < inUserCountBurst ? thread.getThreadNum() : (thread.getThreadNum() - inUserCountBurst) % inUserCount; long startTime = rampUpBucketStartTime + rampUpBucketThreadPosition * additionalRampUp; long endTime = descentPoint + outUserPeriod * (int) Math.floor((double) thread.getThreadNum() / outUserCount); log.debug(String.format("threadNum=%d, rampUpBucket=%d, rampUpBucketThreadCount=%d, rampUpBucketStartTime=%d, rampUpBucketThreadPosition=%d, rampUpDuration=%d, iterationDuration=%d, iterationCountTotal=%d, ascentPoint=%d, descentPoint=%d, startTime=%d, endTime=%d", thread.getThreadNum(), rampUpBucket, rampUpBucketThreadCount, rampUpBucketStartTime, rampUpBucketThreadPosition, rampUpDuration, iterationDuration, iterationCountTotal, ascentPoint, descentPoint, startTime, endTime)); thread.setStartTime(startTime); thread.setEndTime(endTime); thread.setScheduled(true); }
SteppingThreadGroup extends AbstractSimpleThreadGroup { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { int inUserCount = getInUserCountAsInt(); int outUserCount = getOutUserCountAsInt(); if (inUserCount == 0) { inUserCount = getNumThreads(); } if (outUserCount == 0) { outUserCount = getNumThreads(); } int inUserCountBurst = Math.min(getInUserCountBurstAsInt(), getNumThreads()); if (inUserCountBurst <= 0) { inUserCountBurst = inUserCount; } int rampUpBucket = thread.getThreadNum() < inUserCountBurst ? 0 : 1 + (thread.getThreadNum() - inUserCountBurst) / inUserCount; int rampUpBucketThreadCount = thread.getThreadNum() < inUserCountBurst ? inUserCountBurst : inUserCount; long threadGroupDelay = 1000L * getThreadGroupDelayAsInt(); long ascentPoint = tgStartTime + threadGroupDelay; long inUserPeriod = 1000L * getInUserPeriodAsInt(); long additionalRampUp = 1000L * getRampUpAsInt() / rampUpBucketThreadCount; long flightTime = 1000L * getFlightTimeAsInt(); long outUserPeriod = 1000L * getOutUserPeriodAsInt(); long rampUpDuration = 1000L * getRampUpAsInt(); long iterationDuration = inUserPeriod + rampUpDuration; int iterationCountTotal = getNumThreads() < inUserCountBurst ? 1 : (int) Math.ceil((double) (getNumThreads() - inUserCountBurst) / inUserCount); int lastIterationUserCount = (getNumThreads() - inUserCountBurst) % inUserCount; if (lastIterationUserCount == 0) { lastIterationUserCount = inUserCount; } long descentPoint = ascentPoint + iterationCountTotal * iterationDuration + (1000L * getRampUpAsInt() / inUserCount) * lastIterationUserCount + flightTime; long rampUpBucketStartTime = ascentPoint + rampUpBucket * iterationDuration; int rampUpBucketThreadPosition = thread.getThreadNum() < inUserCountBurst ? thread.getThreadNum() : (thread.getThreadNum() - inUserCountBurst) % inUserCount; long startTime = rampUpBucketStartTime + rampUpBucketThreadPosition * additionalRampUp; long endTime = descentPoint + outUserPeriod * (int) Math.floor((double) thread.getThreadNum() / outUserCount); log.debug(String.format("threadNum=%d, rampUpBucket=%d, rampUpBucketThreadCount=%d, rampUpBucketStartTime=%d, rampUpBucketThreadPosition=%d, rampUpDuration=%d, iterationDuration=%d, iterationCountTotal=%d, ascentPoint=%d, descentPoint=%d, startTime=%d, endTime=%d", thread.getThreadNum(), rampUpBucket, rampUpBucketThreadCount, rampUpBucketStartTime, rampUpBucketThreadPosition, rampUpDuration, iterationDuration, iterationCountTotal, ascentPoint, descentPoint, startTime, endTime)); thread.setStartTime(startTime); thread.setEndTime(endTime); thread.setScheduled(true); } }
SteppingThreadGroup extends AbstractSimpleThreadGroup { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { int inUserCount = getInUserCountAsInt(); int outUserCount = getOutUserCountAsInt(); if (inUserCount == 0) { inUserCount = getNumThreads(); } if (outUserCount == 0) { outUserCount = getNumThreads(); } int inUserCountBurst = Math.min(getInUserCountBurstAsInt(), getNumThreads()); if (inUserCountBurst <= 0) { inUserCountBurst = inUserCount; } int rampUpBucket = thread.getThreadNum() < inUserCountBurst ? 0 : 1 + (thread.getThreadNum() - inUserCountBurst) / inUserCount; int rampUpBucketThreadCount = thread.getThreadNum() < inUserCountBurst ? inUserCountBurst : inUserCount; long threadGroupDelay = 1000L * getThreadGroupDelayAsInt(); long ascentPoint = tgStartTime + threadGroupDelay; long inUserPeriod = 1000L * getInUserPeriodAsInt(); long additionalRampUp = 1000L * getRampUpAsInt() / rampUpBucketThreadCount; long flightTime = 1000L * getFlightTimeAsInt(); long outUserPeriod = 1000L * getOutUserPeriodAsInt(); long rampUpDuration = 1000L * getRampUpAsInt(); long iterationDuration = inUserPeriod + rampUpDuration; int iterationCountTotal = getNumThreads() < inUserCountBurst ? 1 : (int) Math.ceil((double) (getNumThreads() - inUserCountBurst) / inUserCount); int lastIterationUserCount = (getNumThreads() - inUserCountBurst) % inUserCount; if (lastIterationUserCount == 0) { lastIterationUserCount = inUserCount; } long descentPoint = ascentPoint + iterationCountTotal * iterationDuration + (1000L * getRampUpAsInt() / inUserCount) * lastIterationUserCount + flightTime; long rampUpBucketStartTime = ascentPoint + rampUpBucket * iterationDuration; int rampUpBucketThreadPosition = thread.getThreadNum() < inUserCountBurst ? thread.getThreadNum() : (thread.getThreadNum() - inUserCountBurst) % inUserCount; long startTime = rampUpBucketStartTime + rampUpBucketThreadPosition * additionalRampUp; long endTime = descentPoint + outUserPeriod * (int) Math.floor((double) thread.getThreadNum() / outUserCount); log.debug(String.format("threadNum=%d, rampUpBucket=%d, rampUpBucketThreadCount=%d, rampUpBucketStartTime=%d, rampUpBucketThreadPosition=%d, rampUpDuration=%d, iterationDuration=%d, iterationCountTotal=%d, ascentPoint=%d, descentPoint=%d, startTime=%d, endTime=%d", thread.getThreadNum(), rampUpBucket, rampUpBucketThreadCount, rampUpBucketStartTime, rampUpBucketThreadPosition, rampUpDuration, iterationDuration, iterationCountTotal, ascentPoint, descentPoint, startTime, endTime)); thread.setStartTime(startTime); thread.setEndTime(endTime); thread.setScheduled(true); } SteppingThreadGroup(); }
SteppingThreadGroup extends AbstractSimpleThreadGroup { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { int inUserCount = getInUserCountAsInt(); int outUserCount = getOutUserCountAsInt(); if (inUserCount == 0) { inUserCount = getNumThreads(); } if (outUserCount == 0) { outUserCount = getNumThreads(); } int inUserCountBurst = Math.min(getInUserCountBurstAsInt(), getNumThreads()); if (inUserCountBurst <= 0) { inUserCountBurst = inUserCount; } int rampUpBucket = thread.getThreadNum() < inUserCountBurst ? 0 : 1 + (thread.getThreadNum() - inUserCountBurst) / inUserCount; int rampUpBucketThreadCount = thread.getThreadNum() < inUserCountBurst ? inUserCountBurst : inUserCount; long threadGroupDelay = 1000L * getThreadGroupDelayAsInt(); long ascentPoint = tgStartTime + threadGroupDelay; long inUserPeriod = 1000L * getInUserPeriodAsInt(); long additionalRampUp = 1000L * getRampUpAsInt() / rampUpBucketThreadCount; long flightTime = 1000L * getFlightTimeAsInt(); long outUserPeriod = 1000L * getOutUserPeriodAsInt(); long rampUpDuration = 1000L * getRampUpAsInt(); long iterationDuration = inUserPeriod + rampUpDuration; int iterationCountTotal = getNumThreads() < inUserCountBurst ? 1 : (int) Math.ceil((double) (getNumThreads() - inUserCountBurst) / inUserCount); int lastIterationUserCount = (getNumThreads() - inUserCountBurst) % inUserCount; if (lastIterationUserCount == 0) { lastIterationUserCount = inUserCount; } long descentPoint = ascentPoint + iterationCountTotal * iterationDuration + (1000L * getRampUpAsInt() / inUserCount) * lastIterationUserCount + flightTime; long rampUpBucketStartTime = ascentPoint + rampUpBucket * iterationDuration; int rampUpBucketThreadPosition = thread.getThreadNum() < inUserCountBurst ? thread.getThreadNum() : (thread.getThreadNum() - inUserCountBurst) % inUserCount; long startTime = rampUpBucketStartTime + rampUpBucketThreadPosition * additionalRampUp; long endTime = descentPoint + outUserPeriod * (int) Math.floor((double) thread.getThreadNum() / outUserCount); log.debug(String.format("threadNum=%d, rampUpBucket=%d, rampUpBucketThreadCount=%d, rampUpBucketStartTime=%d, rampUpBucketThreadPosition=%d, rampUpDuration=%d, iterationDuration=%d, iterationCountTotal=%d, ascentPoint=%d, descentPoint=%d, startTime=%d, endTime=%d", thread.getThreadNum(), rampUpBucket, rampUpBucketThreadCount, rampUpBucketStartTime, rampUpBucketThreadPosition, rampUpDuration, iterationDuration, iterationCountTotal, ascentPoint, descentPoint, startTime, endTime)); thread.setStartTime(startTime); thread.setEndTime(endTime); thread.setScheduled(true); } SteppingThreadGroup(); String getThreadGroupDelay(); void setThreadGroupDelay(String delay); String getInUserPeriod(); void setInUserPeriod(String value); String getInUserCount(); void setInUserCount(String delay); String getInUserCountBurst(); void setInUserCountBurst(String text); String getFlightTime(); void setFlightTime(String delay); String getOutUserPeriod(); void setOutUserPeriod(String delay); String getOutUserCount(); void setOutUserCount(String delay); String getRampUp(); void setRampUp(String delay); int getThreadGroupDelayAsInt(); int getInUserPeriodAsInt(); int getInUserCountAsInt(); int getInUserCountBurstAsInt(); int getRampUpAsInt(); int getFlightTimeAsInt(); int getOutUserPeriodAsInt(); int getOutUserCountAsInt(); void setNumThreads(String execute); String getNumThreadsAsString(); }
SteppingThreadGroup extends AbstractSimpleThreadGroup { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { int inUserCount = getInUserCountAsInt(); int outUserCount = getOutUserCountAsInt(); if (inUserCount == 0) { inUserCount = getNumThreads(); } if (outUserCount == 0) { outUserCount = getNumThreads(); } int inUserCountBurst = Math.min(getInUserCountBurstAsInt(), getNumThreads()); if (inUserCountBurst <= 0) { inUserCountBurst = inUserCount; } int rampUpBucket = thread.getThreadNum() < inUserCountBurst ? 0 : 1 + (thread.getThreadNum() - inUserCountBurst) / inUserCount; int rampUpBucketThreadCount = thread.getThreadNum() < inUserCountBurst ? inUserCountBurst : inUserCount; long threadGroupDelay = 1000L * getThreadGroupDelayAsInt(); long ascentPoint = tgStartTime + threadGroupDelay; long inUserPeriod = 1000L * getInUserPeriodAsInt(); long additionalRampUp = 1000L * getRampUpAsInt() / rampUpBucketThreadCount; long flightTime = 1000L * getFlightTimeAsInt(); long outUserPeriod = 1000L * getOutUserPeriodAsInt(); long rampUpDuration = 1000L * getRampUpAsInt(); long iterationDuration = inUserPeriod + rampUpDuration; int iterationCountTotal = getNumThreads() < inUserCountBurst ? 1 : (int) Math.ceil((double) (getNumThreads() - inUserCountBurst) / inUserCount); int lastIterationUserCount = (getNumThreads() - inUserCountBurst) % inUserCount; if (lastIterationUserCount == 0) { lastIterationUserCount = inUserCount; } long descentPoint = ascentPoint + iterationCountTotal * iterationDuration + (1000L * getRampUpAsInt() / inUserCount) * lastIterationUserCount + flightTime; long rampUpBucketStartTime = ascentPoint + rampUpBucket * iterationDuration; int rampUpBucketThreadPosition = thread.getThreadNum() < inUserCountBurst ? thread.getThreadNum() : (thread.getThreadNum() - inUserCountBurst) % inUserCount; long startTime = rampUpBucketStartTime + rampUpBucketThreadPosition * additionalRampUp; long endTime = descentPoint + outUserPeriod * (int) Math.floor((double) thread.getThreadNum() / outUserCount); log.debug(String.format("threadNum=%d, rampUpBucket=%d, rampUpBucketThreadCount=%d, rampUpBucketStartTime=%d, rampUpBucketThreadPosition=%d, rampUpDuration=%d, iterationDuration=%d, iterationCountTotal=%d, ascentPoint=%d, descentPoint=%d, startTime=%d, endTime=%d", thread.getThreadNum(), rampUpBucket, rampUpBucketThreadCount, rampUpBucketStartTime, rampUpBucketThreadPosition, rampUpDuration, iterationDuration, iterationCountTotal, ascentPoint, descentPoint, startTime, endTime)); thread.setStartTime(startTime); thread.setEndTime(endTime); thread.setScheduled(true); } SteppingThreadGroup(); String getThreadGroupDelay(); void setThreadGroupDelay(String delay); String getInUserPeriod(); void setInUserPeriod(String value); String getInUserCount(); void setInUserCount(String delay); String getInUserCountBurst(); void setInUserCountBurst(String text); String getFlightTime(); void setFlightTime(String delay); String getOutUserPeriod(); void setOutUserPeriod(String delay); String getOutUserCount(); void setOutUserCount(String delay); String getRampUp(); void setRampUp(String delay); int getThreadGroupDelayAsInt(); int getInUserPeriodAsInt(); int getInUserCountAsInt(); int getInUserCountBurstAsInt(); int getRampUpAsInt(); int getFlightTimeAsInt(); int getOutUserPeriodAsInt(); int getOutUserCountAsInt(); void setNumThreads(String execute); String getNumThreadsAsString();  }