RFR: Allow setting of opsPerInvocation from setup functions
bbrehm
duke at openjdk.org
Fri Mar 24 10:05:06 UTC 2023
In many cases, opsPerInvocation is known at the @Setup function, but cannot be reasonably known at any other point. This example is somewhat lame in that regard; I actually needed that for some not-quite-micro benchmarks (the setup function loads real-ish data from disk, and the opsPerInvocation depends on the data that has been loaded).
Since every good example teaches multiple things, I added one that also warns about the branch history table stitching together surprisingly long patterns.
The super-duper correct way of doing this example (cf https://discourse.julialang.org/t/psa-microbenchmarks-remember-branch-history/17436) would be to have constant opsPerInvocation and one large array; then a smaller (@Param) array is copied into that multiple times. Thus we could exclude effects of memory hierarchy. That would look quite unnatural and harder to relate to "normal looking" code (and there are no effects of memory anyway, since first, the benchmark is too slow to saturate DRAM bandwidth, and second even the largest set fits into L2).
-------------
Commit messages:
- add setter function for opsPerInvocation; use it in example
- add example, using reflection
Changes: https://git.openjdk.org/jmh/pull/97/files
Webrev: https://webrevs.openjdk.org/?repo=jmh&pr=97&range=00
Stats: 163 lines in 2 files changed: 162 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jmh/pull/97.diff
Fetch: git fetch https://git.openjdk.org/jmh.git pull/97/head:pull/97
PR: https://git.openjdk.org/jmh/pull/97
More information about the jmh-dev
mailing list