|
|
@ -0,0 +1,55 @@ |
|
|
|
#include <iostream>
|
|
|
|
#include "ChaPRNG.h"
|
|
|
|
#include <benchmark/benchmark.h>
|
|
|
|
#include <chrono>
|
|
|
|
#include <random>
|
|
|
|
|
|
|
|
using namespace std::chrono_literals; |
|
|
|
|
|
|
|
|
|
|
|
template<int T, bool u, bool v> |
|
|
|
static void PRNGBuild(benchmark::State& state) { |
|
|
|
std::random_device dev; |
|
|
|
std::array<uint32_t,12> seed{ |
|
|
|
dev(),dev(),dev(),dev(), |
|
|
|
dev(),dev(),dev(),dev(), |
|
|
|
dev(),dev(),dev(),dev() |
|
|
|
}; |
|
|
|
ChaPRNG<T,u,v> prng(seed); |
|
|
|
for(auto _ : state) |
|
|
|
prng(); |
|
|
|
} |
|
|
|
|
|
|
|
BENCHMARK(PRNGBuild<8, false, false>); |
|
|
|
BENCHMARK(PRNGBuild<12, false, false>); |
|
|
|
BENCHMARK(PRNGBuild<16, false, false>); |
|
|
|
BENCHMARK(PRNGBuild<20, false, false>); |
|
|
|
|
|
|
|
BENCHMARK(PRNGBuild<8, true, false>); |
|
|
|
BENCHMARK(PRNGBuild<12, true, false>); |
|
|
|
BENCHMARK(PRNGBuild<16, true, false>); |
|
|
|
BENCHMARK(PRNGBuild<20, true, false>); |
|
|
|
|
|
|
|
BENCHMARK(PRNGBuild<8, false, true>); |
|
|
|
BENCHMARK(PRNGBuild<12, false, true>); |
|
|
|
BENCHMARK(PRNGBuild<16, false, true>); |
|
|
|
BENCHMARK(PRNGBuild<20, false, true>); |
|
|
|
|
|
|
|
BENCHMARK(PRNGBuild<4, true, true>); |
|
|
|
BENCHMARK(PRNGBuild<6, true, true>); |
|
|
|
BENCHMARK(PRNGBuild<8, true, true>); |
|
|
|
BENCHMARK(PRNGBuild<12, true, true>); |
|
|
|
BENCHMARK(PRNGBuild<16, true, true>); |
|
|
|
BENCHMARK(PRNGBuild<20, true, true>); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void std_mtPRNGBuild(benchmark::State& state) { |
|
|
|
std::random_device dev; |
|
|
|
std::mt19937 prng(dev()); |
|
|
|
for(auto _ : state) |
|
|
|
prng(); |
|
|
|
} |
|
|
|
BENCHMARK(std_mtPRNGBuild); |
|
|
|
|
|
|
|
BENCHMARK_MAIN(); |