【问题标题】:Json output from Vegeta HTTP load testingVegeta HTTP 负载测试的 Json 输出
【发布时间】:2019-04-24 12:36:14
【问题描述】:

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

vegeta 攻击 -targets="./vegeta_sagemaker_True.txt" -rate=10 -duration=2s | vegeta 报告 -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 "
  ]
}

有人知道为什么会这样吗?

谢谢!

【问题讨论】:

  • “非常奇怪的数字”是指latencies 字段中的数字吗?
  • @shaochuancs 完全正确!例如持续时间。

标签: http command-line-interface load-testing vegeta


【解决方案1】:

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

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

实际上,在 vegeta 中,如果您将 type 声明为 text (-type=text),它将使用 NewTextReporter,并将 time.Duration 打印为用户友好的字符串。如果将type 声明为json (-type=json),它将使用NewJSONReporter 并返回time.Duration 的内部表示:

Duration 表示两个瞬间之间经过的时间,以 int64 纳秒计数。该表示将最大可表示的持续时间限制为大约 290 年。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多