[Bench!][Mir] +54%..+185% performance boost for Mersenne Twister.
Joseph Rushton Wakeling via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 13 13:56:36 PST 2016
On Tuesday, 13 December 2016 at 18:15:25 UTC, Joseph Rushton
Wakeling wrote:
> I'm going to try to put together a range-based version to see
> if this also makes any difference. I'll post some benchmarks
> of my own once that's done, and if all looks good I'll try to
> put a Phobos PR together.
Benchmark is here:
https://github.com/WebDrake/mersenne-twister-range
Overall these benchmarks seem to have reasonably wide variance.
I note that the original benchmark's attempt to make the code
"hot" had quite a strong impact in terms of the ordering of
individual benchmarks; I've tried to work around that by doing
the "make it hot" loop immediately before the benchmark.
This is still just a plain old foreach, so it may be worth
exploring some benchmarks where other stuff is done with the
random variates. As a first step I've added some benchmarks
using `uniform`.
Sample output from 2 different runs of these benchmarks:
-----
Running ./mir-mt-range
opCall Mir 32-bit Mt19937: 6.68058 Gb/s
check sum = 429472035921730457
range Mir 32-bit Mt19937: 6.639 Gb/s
check sum = 429472031909629874
opCall Mir 64-bit Mt19937: 14.0351 Gb/s
check sum = 5606740663277085587
range Mir 64-bit Mt19937: 13.8229 Gb/s
check sum = 3636092631268073456
Phobos 32-bit Mt19937: 4.22164 Gb/s
check sum = 429472035921730457
Phobos 64-bit Mt19937: wrong initialization and tempering
range Mir 32-bit Mt19937: 95.4198 U(0.0, 1.0) variates/s
range Mir 64-bit Mt19937: 87.184 U(0.0, 1.0) variates/s
Phobos 32-bit Mt19937: 80.8407 U(0.0, 1.0) variates/s
----
----
Running ./mir-mt-range
opCall Mir 32-bit Mt19937: 6.36183 Gb/s
check sum = 429472035921730457
range Mir 32-bit Mt19937: 6.54397 Gb/s
check sum = 429472031909629874
opCall Mir 64-bit Mt19937: 13.7339 Gb/s
check sum = 5606740663277085587
range Mir 64-bit Mt19937: 13.8229 Gb/s
check sum = 3636092631268073456
Phobos 32-bit Mt19937: 4.18848 Gb/s
check sum = 429472035921730457
Phobos 64-bit Mt19937: wrong initialization and tempering
range Mir 32-bit Mt19937: 95.2381 U(0.0, 1.0) variates/s
range Mir 64-bit Mt19937: 97.0874 U(0.0, 1.0) variates/s
Phobos 32-bit Mt19937: 88.1057 U(0.0, 1.0) variates/s
----
More information about the Digitalmars-d
mailing list