Path to this page:
Subject: CVS commit: wip/ocaml-pa_bench
From: Hiramatsu Yoshifumi
Date: 2015-02-26 17:02:45
Message id: E1YR0tz-0008H4-Uq@sfs-ml-1.v29.ch3.sourceforge.com
Log Message:
Update ocaml-pa_bench to 112.06.00.
Changes from previous:
----------------------
- Made the code generated by `pa_bench` for `BENCH` not use `ignore`,
because OCaml 4.02 will remove dead code in some cases, meaning the
benchmarks are no longer measuring what they should. Instead the ignore
is deep inside `Core_bench`, which is likely out of reach of the
compiler.
The result of the user functions given to `BENCH_FUN` and
`BENCH_INDEXED` are changed so they don't have to return unit and
people are encouraged not to use `ignore` when these functions don't
return `unit` (you will get the same warning though, i.e. a warning
if the result of your function is a function too, thus preventing
unintended partial applications).
For example, here are a few benchmarks and their output before the
fix:
let x = if Random.bool () then 100 else 1001
let r = ref 0
BENCH "ig-1" = 10 / x
BENCH "ig-2" = ()
BENCH "ig-3" = phys_equal (10 / x) (Obj.magic 0)
BENCH "ig-4" = r := (10 / x)
BENCH "ig-5" = r := x
+----------------+----------+------------+
| Name | Time/Run | Percentage |
+----------------+----------+------------+
| [misc.ml] ig-1 | 3.92ns | 29.30% |
| [misc.ml] ig-2 | 3.34ns | 24.95% |
| [misc.ml] ig-3 | 3.91ns | 29.23% |
| [misc.ml] ig-4 | 13.37ns | 100.00% |
| [misc.ml] ig-5 | 3.24ns | 24.20% |
+----------------+----------+------------+
Many of the the numbers above are much lower than they should be
because of the implicit ignores inserted by the benchmark caused the
division to to eliminated by the compiler. After the fix, the same
benchmarks produced more meaningful numbers:
+----------------+----------+------------+
| Name | Time/Run | Percentage |
+----------------+----------+------------+
| [misc.ml] ig-1 | 12.78ns | 94.55% |
| [misc.ml] ig-2 | 3.23ns | 23.90% |
| [misc.ml] ig-3 | 13.51ns | 99.94% |
| [misc.ml] ig-4 | 13.52ns | 100.00% |
| [misc.ml] ig-5 | 3.30ns | 24.40% |
+----------------+----------+------------+
Files: