本文整理匯總了Java中org.apache.jmeter.samplers.SampleResult.getResponseCode方法的典型用法代碼示例。如果您正苦於以下問題:Java SampleResult.getResponseCode方法的具體用法?Java SampleResult.getResponseCode怎麽用?Java SampleResult.getResponseCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.getResponseCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}