我正在使用Vegeta做一些压力测试,但我在生成json报告时遇到了一些困难。运行以下命令,我能够看到文本结果:
vegeta攻击-targets=“/ vegeta _sag怪人_True.txt”-rate=10 -duration=2s \vegeta report -output="attack.json“-type=text
Requests [total, rate] 20, 10.52
Duration [total, attack, wait] 2.403464884s, 1.901136s, 502.328884ms
Latencies [mean, 50, 95, 99, max] 945.385864ms, 984.768025ms, 1.368113304s, 1.424427549s, 1.424427549s
Bytes In [total, mean] 5919, 295.95
Bytes Out [total, mean] 7104, 355.20
Success [ratio] 95.00%
Status Codes [code:count] 200:19 400:1
Error Set:
400 当我运行相同的命令,将类型文本更改为-type=json时,我会收到非常奇怪的数字,而这些数字对我来说没有意义:
{
"latencies": {
"total": 19853536952,
"mean": 992676847,
"50th": 972074984,
"95th": 1438787021,
"99th": 1636579198,
"max": 1636579198
},
"bytes_in": {
"total": 5919,
"mean": 295.95
},
"bytes_out": {
"total": 7104,
"mean": 355.2
},
"earliest": "2019-04-24T14:32:23.099072+02:00",
"latest": "2019-04-24T14:32:25.00025+02:00",
"end": "2019-04-24T14:32:25.761337546+02:00",
"duration": 1901178000,
"wait": 761087546,
"requests": 20,
"rate": 10.519793517492838,
"success": 0.95,
"status_codes": {
"200": 19,
"400": 1
},
"errors": [
"400 "
]
}有人知道为什么会发生这种事吗?
谢谢!
发布于 2019-04-25 08:59:44
这些数字是纳秒-- time.Duration在Go中的内部表示。
例如,JSON中的latencies.mean是992676847,这意味着992676847纳秒,即992676847/1000/1000 = 992.676847ms。
实际上,在vegeta中,如果您将type声明为text (-type=text),它将使用NewTextReporter,并将time.Duration打印为一个用户友好的字符串。如果您声明type为json (-type=json),它将使用NewJSONReporter并返回time.Duration的内部表示:
持续时间以int64纳秒计数表示两个瞬间之间的运行时间。代表人数将可代表的最长期限限制在大约290年。
https://stackoverflow.com/questions/55830207
复制相似问题