JMeter 并没有提供这么详细的区分——至少目前尚未发现,但是在 JMeter 的执行结果中也有一个字段可以利用一下。如果想看到这一项,首先要设置将 JMeter 运行结果保存到 XML 格式。
在 JMeter.properties 中找到
JMeter.save.saveservice.output_format=csv 改为
JMeter.save.saveservice.output_format=xml
重新启动 JMeter ,执行一个脚本并保存测试结果。
使用任何一个文本编辑工具打开 .jtl 文件,内容如下:
1
<?
xml version="1.0" encoding="UTF-8"
?>
2 < testResults version ="1.2" >
3 < httpSample t ="2969" lt ="1906" ts ="1159349557390" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-1" dt ="text" ng ="5" na ="5" />
4 < httpSample t ="2797" lt ="1719" ts ="1159349557609" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-2" dt ="text" ng ="5" na ="5" />
5 < httpSample t ="2625" lt ="1594" ts ="1159349558015" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-4" dt ="text" ng ="5" na ="5" />
6 < httpSample t ="2843" lt ="1812" ts ="1159349557812" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-3" dt ="text" ng ="5" na ="5" />
7 < httpSample t ="2687" lt ="1110" ts ="1159349558218" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-5" dt ="text" ng ="5" na ="5" />
8 < httpSample t ="844" lt ="391" ts ="1159349560374" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-1" dt ="text" ng ="5" na ="5" />
9 < httpSample t ="843" lt ="437" ts ="1159349560406" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-2" dt ="text" ng ="4" na ="4" />
10 < httpSample t ="781" lt ="422" ts ="1159349560640" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-4" dt ="text" ng ="3" na ="3" />
11 < httpSample t ="782" lt ="391" ts ="1159349560905" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-5" dt ="text" ng ="2" na ="2" />
12 < httpSample t ="1188" lt ="485" ts ="1159349560655" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-3" dt ="text" ng ="1" na ="1" />
13
14 </ testResults >
15
2 < testResults version ="1.2" >
3 < httpSample t ="2969" lt ="1906" ts ="1159349557390" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-1" dt ="text" ng ="5" na ="5" />
4 < httpSample t ="2797" lt ="1719" ts ="1159349557609" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-2" dt ="text" ng ="5" na ="5" />
5 < httpSample t ="2625" lt ="1594" ts ="1159349558015" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-4" dt ="text" ng ="5" na ="5" />
6 < httpSample t ="2843" lt ="1812" ts ="1159349557812" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-3" dt ="text" ng ="5" na ="5" />
7 < httpSample t ="2687" lt ="1110" ts ="1159349558218" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-5" dt ="text" ng ="5" na ="5" />
8 < httpSample t ="844" lt ="391" ts ="1159349560374" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-1" dt ="text" ng ="5" na ="5" />
9 < httpSample t ="843" lt ="437" ts ="1159349560406" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-2" dt ="text" ng ="4" na ="4" />
10 < httpSample t ="781" lt ="422" ts ="1159349560640" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-4" dt ="text" ng ="3" na ="3" />
11 < httpSample t ="782" lt ="391" ts ="1159349560905" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-5" dt ="text" ng ="2" na ="2" />
12 < httpSample t ="1188" lt ="485" ts ="1159349560655" s ="true" lb ="http://jackei.cnblogs.com/" rc ="200" rm ="OK" tn ="Thread Group 1-3" dt ="text" ng ="1" na ="1" />
13
14 </ testResults >
15
找到 lt 这一项。
结合 JMeter 的几篇文章和 email,解释一下 lt 的意思。
lt = latency time (ms)
在 JMeter 中执行一个脚本时,大概的过程如下:
Start timer
Send Request
Wait for data
Initial (first) response packet occurs - this is latency
more data
...
end of response
Stop timer - this is the response time
而上面的 XML 文件中,t 这一项表示的是 elapsed time。也就是一个请求从发出到收到完整的响应的时间。
这里可以看到 lt 是接收到响应的第一个包的时间。
那么 lt 就相当于 LR 中的 Server time,而 t-lt 就相当于 LR 中的 Netwrok time。