Open awygle opened 5 years ago
After seeing https://github.com/bheisler/criterion.rs/pull/283 I tested again with the git version of criterion
. Unfortunately this didn't correct the issue - if anything, it made base
slightly slower.
Hey, thanks for trying Criterion.rs, and thanks for the bug report.
I have to admit, I'm completely mystified by that. I do all of my development on Windows (although generally under WSL, rather than in Windows proper) and I've never noticed this. And yeah, now that you mention it - I do see substantial differences between WSL and windows even running the same benchmarks with the gnu linker.
Unfortunately, I'm not really an expert on the subtle differences in performance between operating systems so I'm not really the right person to figure this out in detail. The fact that I'm seeing it in WSL, and not a Linux VM suggests to me that it might have something to do with Windows vs. Linux versions of rustc, rather than the operating systems, but I can't really back that up.
The only advice I can offer is that a couple nanoseconds of difference in performance is actually pretty low-overhead for most benchmarks. The example benchmark you've shown is kind of a worst-case-scenario for measurement overhead; for more substantial benchmarks the measurement overhead will definitely drop as a percentage of the overall time and should actually drop in absolute value as well. Most benchmarks are large relative to the measurement overhead and so that overhead doesn't really matter much in practice most of the time. If your benchmarks are not substantially larger than the measurement overhead, then I'm afraid I'm going to have to disappoint you. Perhaps check back in the future. I do hope to add support for hardware performance counters at some point; those are better tools for highly precise measurements of very small functions.
On Windows,
iter_batched
anditer_batched_ref
seem to add a significant amount of overhead compared toiter
. The following benchmark file:Gives the following results on Windows:
But the following results on a Linux VM running on the same host PC:
As you can see,
iter_batched
runs around 3 times faster on Linux than Windows, anditer_batched_ref
runs around twice as fast. Compared tobase
,iter_batched
is around 2.5 times slower on Windows and around 1.3 times faster on Linux, whileiter_batched_ref
is about 2 times slower on Windows and around 1.2 times faster on Linux.I tried this on current stable and current nightly with similar results. I also tried -msvc and -gnu on Windows with similar results. All measurements were taken with the latest version of
criterion
.