这两个字段有什么区别? :
它们每个是如何计算的?
示例输出:
Time per request: 3953.446 [ms] (mean)
Time per request: 39.534 [ms] (mean, across all concurrent requests)
为什么差别这么大?
最佳答案
下面是一个 ab 的测试结果的例子。我使用 3 并发请求发出 1000 请求。
C:\>ab -d -e a.csv -v 1 -n 1000 -c 3 http://www.example.com/index.aspx
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.m-taoyuan.tw (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Microsoft-IIS/6.0
Server Hostname: www.m-taoyuan.tw
Server Port: 80
Document Path: /index.aspx
Document Length: 25986 bytes
Concurrency Level: 3
Time taken for tests: 25.734375 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 26372000 bytes
HTML transferred: 25986000 bytes
Requests per second: 38.86 [#/sec] (mean)
Time per request: 77.203 [ms] (mean)
Time per request: 25.734 [ms] (mean, across all concurrent requests)
Transfer rate: 1000.72 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 4.4 0 15
Processing: 62 75 9.1 78 109
Waiting: 46 64 8.0 62 109
Total: 62 76 9.3 78 109
如您所见,每个请求 字段有两个 时间。
请先检查 测试时间 字段。该值为 25.734375 秒,即 25734.375 ms 0x25181921123411
如果我们把 25734.375 MS 通过 1000 ,你 25.734 [毫秒] 这是确切的每个请求的时间(平均值,所有并发请求)字段的值。
对于 Time per request (mean) ,值为 77.203 [ms] 。该值比 每个请求的时间(平均,跨所有并发请求) 稍长。那是因为(平均值)被每个特定请求计算并计算它的平均时间。
让我给你举个简单的例子。
假设我们使用 3 个并发连接发出 3 个请求。 测试时间 将是 90ms 并且每个请求是 40ms, 50ms, 。那么这两个 Time per request 的值是多少?
希望你能理解。 :)
关于apachebench - Apache 工作台 : Mean vs Mean across all concurrent requests,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15730677/