Json Vegeta HTTP 负载测试的输出

Json output from Vegeta HTTP load testing

我正在使用 Vegeta 进行压力测试,但在生成 json 报告时遇到了一些问题。 运行 以下命令我能够看到文本结果:

贝吉塔攻击 -targets="./vegeta_sagemaker_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-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 "
  ]
}

有谁知道为什么会这样?

谢谢!

这些数字是纳秒——time.Duration 在 Go 中的内部表示。

比如JSON中的latencies.mean992676847,表示992676847纳秒,即992676847/1000/1000 = 992.676847ms。

实际上,在vegeta中,如果你将type声明为text-type=text),它将使用NewTextReporter, and print the time.Duration as a user-friendly string. If you declare type as json (-type=json), it will use NewJSONReporter and return time.Duration的内部表示:

A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.