我正在使用 Vegeta 进行一些压力测试,但在生成 json 报告时遇到了一些麻烦。运行以下命令,我能够看到文本结果:
贝吉塔攻击 -目标="./vegeta_sagemaker_True.txt" -速率=10 -持续时间=2s | 贝吉塔报告 -输出="攻击.json" -类型=文本
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-text 更改为 -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 "
]
}
有谁知道为什么会这样?
谢谢!
这些数字是纳秒 - Go中time.Duration
的内部表示。
例如,JSON 中的latencies.mean
是 992676847
,这意味着 992676847 纳秒,即 992676847/1000/1000 = 992.676847ms。
实际上,在 vegeta 中,如果您将type
声明为 text
(-type=text
(,它将使用 NewTextReporter,并将time.Duration
打印为用户友好的字符串。如果你将type
声明为 json
(-type=json
(,它将使用 NewJSONReporter 并返回时间。持续时间的内部表示:
持续时间表示两个时刻之间的经过时间,以 int64 纳秒计数表示。该表示将最大可表示持续时间限制为大约 290 年。