Skip to content
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

Q: How to print milliseconds using an output template? #107

Open
lprc opened this issue Mar 4, 2024 · 1 comment
Open

Q: How to print milliseconds using an output template? #107

lprc opened this issue Mar 4, 2024 · 1 comment

Comments

@lprc
Copy link

lprc commented Mar 4, 2024

I'm using the following very simple template for CSV-output, which works fine (stripped down from the CSV-template that nanobench comes with).

"name";"elapsed";"unit"
{{#result}}"{{name}}";{{minimum(elapsed)}};"{{unit}}"
{{/result}}

However I'd like to print elapsed in milliseconds instead of seconds. Is that possible using a template?

(Plus I don't understand why unit prints "op" instead of "seconds".)

I would also be fine with an alternative solution. E.g. before I used the following to get the minimum time over all measurements.

// Get minimum of all epochs in ms
double minTime = 1000000;
for (auto r : bench.results())
    if (r.minimum(ankerl::nanobench::Result::Measure::elapsed) < minTime)
        minTime = r.minimum(ankerl::nanobench::Result::Measure::elapsed) * 1000.0;

However, I'd also like to selectively get the minimum time per name, for which I didn't find an intuitive solution yet. The upper one already feels a bit hacky since there is no example or documentation on this.

Thank you!

@0xB10C
Copy link

0xB10C commented Apr 9, 2024

I've run into a similar issue, though in my case it would be nice to render nanosecond instead of seconds for bitcoin/bitcoin#27284 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants