Java Code Examples for org.apache.jmeter.samplers.SampleResult#getLatency()

The following examples show how to use org.apache.jmeter.samplers.SampleResult#getLatency() . 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: AggregatedTypeUpdater.java    From jmeter-prometheus-plugin with Apache License 2.0 6 votes vote down vote up
protected long measure(SampleEvent event) {
	SampleResult result = event.getResult();
	switch(this.config.getMeasuringAsEnum()) {
	case ResponseSize:
		return result.getBodySizeAsLong();
	case ResponseTime:
		return result.getTime();
	case Latency:
		return result.getLatency();
	case IdleTime:
		return result.getIdleTime();
	case ConnectTime:
		return result.getConnectTime();
	default:
		return 0;
	}
}
 
Example 2
Source File: LatenciesOverTimeGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void add(SampleResult res) {
    if (!isSampleIncluded(res)) {
        return;
    }
    super.add(res);

    long latency = res.getLatency();

    if (isFromTransactionControler(res)) {
        SampleResult[] subResults = res.getSubResults();
        for (int i = 0; i < subResults.length; i++) {
            latency += subResults[i].getLatency();
        }
    }
    addThreadGroupRecord(res.getSampleLabel(),
            normalizeTime(res.getEndTime()), latency);
    updateGui(null);
}
 
Example 3
Source File: ConsoleStatusLogger.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void sampleOccurred(SampleEvent se) {
    // TODO: make the interval configurable
    long sec = System.currentTimeMillis() / 1000;
    if (sec != cur && count > 0) {
        if (cur == 0) {
            begin = sec;
        }

        log.debug(cur + " " + begin);
        flush(sec - begin);
        cur = sec;
    }
    SampleResult res = se.getResult();

    count++;
    sumRTime += res.getTime();
    sumLatency += res.getLatency();
    errors += res.isSuccessful() ? 0 : 1;
    threads = res.getAllThreads();
}
 
Example 4
Source File: JSONConverter.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
private static Map<String, Object> getMainMetrics(List<SampleResult> list) {
    long first = Long.MAX_VALUE;
    long last = 0;
    long failed = 0;
    long bytesCount = 0;
    long sumTime = 0;
    long sumLatency = 0;
    Long[] rtimes = new Long[list.size()];
    int counter = 0;

    for (SampleResult sample : list) {
        long endTime = sample.getEndTime();

        if (endTime < first) {
            first = endTime;
        }

        if (endTime > last) {
            last = endTime;
        }

        if (!sample.isSuccessful()) {
            failed++;
        }

        bytesCount += sample.getBytes();
        sumTime += sample.getTime();
        sumLatency += sample.getLatency();
        rtimes[counter] = sample.getTime();
        counter++;
    }

    final Map<String, Object> results = new HashMap<>();

    results.put("first", first);
    results.put("last", last);
    results.put("failed", failed);
    results.put("bytesCount", bytesCount);
    results.put("sumTime", sumTime);
    results.put("sumLatency", sumLatency);
    results.put("rtimes", rtimes);

    return results;
}