Java Code Examples for org.apache.jmeter.threads.JMeterThread#setEndTime()

The following examples show how to use org.apache.jmeter.threads.JMeterThread#setEndTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UltimateThreadGroup.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
protected void scheduleThread(JMeterThread thread, long tgStartTime) {
    log.debug("Scheduling thread: " + thread.getThreadName());
    if (threadsToSchedule < 1) {
        if (!scheduleIT.hasNext()) {
            throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName());
        }

        currentRecord = (CollectionProperty) scheduleIT.next();
        threadsToSchedule = currentRecord.get(0).getIntValue();
    }

    int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue();
    int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue();
    int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue();
    int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue();
    int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue();

    long ascentPoint = tgStartTime + 1000 * initialDelay;
    final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads);
    long startTime = ascentPoint + rampUpDelayForThread;
    long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread;

    thread.setStartTime(startTime);
    thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads));

    thread.setScheduled(true);
    threadsToSchedule--;
}
 
Example 2
Source File: SteppingThreadGroup.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
@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;
    //number of complete iteration, ie full (in user time + rampup duration) used
    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);
}