-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON reporter for "deno bench" subcommand #14385
Comments
Is there any progress on this? |
No progress so far. PRs and help would be highly appreciated. |
Gotta wait for someone to take the stick, I'm not familiar with Rust at all 😅 |
That is the feature I need, and I will be happy to spend some evenings implementing it. I need some more input. For me, a JSON file with the BenchReport in it would be enough. Is that what everybody wants? The way to switch between reporters Do we want to specify the benchmark results location? Something like optional |
+1 on the console suggestion, but I prefer the label
|
@jsejcksn Thank you for the input. On My idea is to add one more reporter which will produce JSON output. And I like the idea of outputting it to |
@Lurk According to the examples in the manual, the benchmarking tool currently always outputs to the |
@jsejcksn There will be no changes to the output destination, only its format. Updated plan:
Example usage:
|
Why not just |
@iuioiua I think the idea is to allow for additional future reporter serialization formats (e.g. CSV). Having a dedicated boolean argument for every future reporter could become unwieldy — and trying to use them in combination wouldn't make sense (e.g. |
I'm unaware of any other subcommands supporting CSV output. Are there any plans to add support for CSV output for any subcommands? If not, I don't see why |
@iuioiua The internal implementation of reporters suggests that there can be multiple implementations. I want to add JSON, someone else will want to add CSV, YAML, XML, or whatever else is out there. If we add just a boolean flag, we are adding a breaking change for the future. UPD. I still like |
I would also be interested in the |
Does anyone have a proposed format for the JSON output? |
Taken from the manual, this
could look like this where the time unit is seconds. [
{
"cpu": "Apple M1 Max",
"runtime": "deno 1.21.0 (aarch64-apple-darwin)",
"file": "/dev/deno/time_bench.ts",
"group": "timing",
"results": [
{
"name": "Date.now()",
"avg": 125e-9,
"min": 118.98e-9,
"max": 559.95e-9,
"p75": 123.62e-9,
"p99": 150.69e-9,
"p995": 156.63e-9
},
{
"name": "performance.now()",
"avg": 2.67e-6,
"min": 2.64e-6,
"max": 2.82e-6,
"p75": 2.67e-6,
"p99": 2.82e-6,
"p995": 2.82e-6
}
]
}
] |
I think that's in the right direction, and here is some feedback:
The SI unit of time is seconds, and without some kind of self-documenting unit, seconds are very reasonable. Another reference is UNIX time.
Is it safe to assume that remote URLs are supported? If so, then perhaps the key could be something like "url": "file:///dev/deno/time_bench.ts", |
IMO the second is too big as a standard unit of measurement for benchmarking. In JavaScript land, everything is millisecond If we look at the example output @iuioiua gave
Even a nanosecond precision is not enough. 9_007_199_254_740_991 is the max value we can safely use in JSON. 9_007_199_254_740_991 nanoseconds are roughly 104 days, which sounds like a pretty reasonable number for benchmarking. I would say we should use nanoseconds as a unit of measurement. It can be easily upscaled to seconds or even days if someone needs it, and at the same time gives more precision which is important when you are in a measuring contest. |
Actually, milliseconds is likely the best unit because it's consistent with other time-related APIs. Precision isn't an issue thanks to decimals. |
Just to clarify Nanoseconds:
Milliseconds:
|
It's also worth noting that in most cases, the JSON data printed will be consumed by some script or similar and doesn't need to be human-readable. So the number of significant figures isn't super important. |
@bartlomieju Should we close this one? |
Yeah, thanks for the ping! |
Hopefully we could do it for v1.22 to allow stabilization of "Deno.bench()" API.
The text was updated successfully, but these errors were encountered: