giltene / wrk2

A constant throughput, correct latency recording variant of wrk
Apache License 2.0
4.28k stars 395 forks source link

What's the unit of latency used in lua scripting? #122

Closed yukha-dw closed 2 years ago

yukha-dw commented 2 years ago

Hello, i make simple lua script to make me send wrk result easier. As my current understanding, the latency and duration is in 'us' ? But when i tried to test something, the result is not what i expected, the duration is normal (5 min = 300s), but latency is 1000 times larger than in millisecond

Should i redivide the latency by 1000 to make it in millisecond?

result:

        "latency_min": "10000.00",
        "latency_max": "300000.00",
        "latency_mean": "200000.00",
        "latency_stdev": "90000.00",
        "latency_99": "300000.00",
        "duration": "300.00",

script:

done = function(summary, latency, requests)
    io.write('\nJSON Summary\n')
    result = "{"..
    string.format('"latency_min": "%.2f", ', latency.min/1000)..
    string.format('"latency_max": "%.2f", ', latency.max/1000)..
    string.format('"latency_mean": "%.2f", ', latency.mean/1000)..
    string.format('"latency_stdev": "%.2f", ', latency.stdev/1000)..
    string.format('"latency_99": "%.2f", ', latency:percentile(99)/1000)..
    string.format('"duration": "%.2f", ', summary.duration/1000000)..
    string.format('"requests": "%d", ', summary.requests)..
    string.format('"bytes": "%d", ', summary.bytes)..
    string.format('"errors": "%d", ', summary.errors.status)..
    "}";

    io.write(result)
end
yukha-dw commented 2 years ago

nevermind, the divider is right, i tested it with a potato and the number went straight up without timeout settings triggered, weird.