本文整理匯總了Java中org.apache.jmeter.samplers.SampleResult.getTime方法的典型用法代碼示例。如果您正苦於以下問題:Java SampleResult.getTime方法的具體用法?Java SampleResult.getTime怎麽用?Java SampleResult.getTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.getTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAggregateSecond
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
private JSONObject getAggregateSecond(Long sec, List<SampleResult> raw) {
/*
"rc": item.http_codes,
"net": item.net_codes
*/
JSONObject result = new JSONObject();
Date ts = new Date(sec * 1000);
log.debug("Aggregating " + sec);
result.put("ts", format.format(ts));
int avg_rt = 0;
Long[] rtimes = new Long[raw.size()];
String[] rcodes = new String[raw.size()];
int cnt = 0;
int failedCount = 0;
long maxThreadCount = 0;
for (SampleResult res : raw) {
if (maxThreadCount < res.getAllThreads()) {
maxThreadCount = res.getAllThreads();
}
avg_rt += res.getTime();
rtimes[cnt] = res.getTime();
rcodes[cnt] = res.getResponseCode();
if (!res.isSuccessful()) {
failedCount++;
}
cnt++;
}
result.put("rps", cnt);
result.put("threads", maxThreadCount);
result.put("avg_rt", avg_rt / cnt);
result.put("quantiles", getQuantilesJSON(rtimes));
result.put("net", getNetJSON(failedCount, cnt - failedCount));
result.put("rc", getRCJSON(rcodes));
result.put("planned_rps", 0); // JMeter has no such feature like Yandex.Tank
return result;
}
示例2: getMainMetrics
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
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;
}