diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/random/benchmark/prng | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/random/benchmark/prng')
-rw-r--r-- | util/random/benchmark/prng/main.cpp | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/util/random/benchmark/prng/main.cpp b/util/random/benchmark/prng/main.cpp index 2c6279ff71..cc2b80d8a6 100644 --- a/util/random/benchmark/prng/main.cpp +++ b/util/random/benchmark/prng/main.cpp @@ -2,122 +2,122 @@ #include <util/random/entropy.h> #include <util/random/fast.h> -#include <util/random/normal.h> +#include <util/random/normal.h> #include <util/random/mersenne.h> #include <util/system/compiler.h> -#include <util/generic/xrange.h> - -#include <random> - -// double part -Y_CPU_BENCHMARK(Mersenne32_Double, p) { - TMersenne<ui32> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; +#include <util/generic/xrange.h> + +#include <random> + +// double part +Y_CPU_BENCHMARK(Mersenne32_Double, p) { + TMersenne<ui32> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); } } -Y_CPU_BENCHMARK(Mersenne64_Double, p) { - TMersenne<ui64> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; +Y_CPU_BENCHMARK(Mersenne64_Double, p) { + TMersenne<ui64> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); } } -Y_CPU_BENCHMARK(Fast32_Double, p) { - TFastRng<ui32> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; +Y_CPU_BENCHMARK(Fast32_Double, p) { + TFastRng<ui32> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); } } -Y_CPU_BENCHMARK(Fast64_Double, p) { - TFastRng<ui64> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; +Y_CPU_BENCHMARK(Fast64_Double, p) { + TFastRng<ui64> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); } } - -// integer part -Y_CPU_BENCHMARK(mt19937_32, p) { - std::mt19937 mt; - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - - Y_DO_NOT_OPTIMIZE_AWAY(mt()); - } -} - -Y_CPU_BENCHMARK(mt19937_64, p) { - std::mt19937_64 mt; - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - - Y_DO_NOT_OPTIMIZE_AWAY(mt()); - } -} - -Y_CPU_BENCHMARK(Mersenne32_GenRand, p) { - TMersenne<ui32> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); - } -} - -Y_CPU_BENCHMARK(Mersenne64_GenRand, p) { - TMersenne<ui64> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); - } -} - -Y_CPU_BENCHMARK(Fast32_GenRand, p) { - TFastRng<ui32> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); - } -} - -Y_CPU_BENCHMARK(Fast64_GenRand, p) { - TFastRng<ui64> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); - } -} - -Y_CPU_BENCHMARK(StlNormal, p) { - TFastRng<ui64> rng(Seed()); - std::normal_distribution<double> d(1.0, 0.0); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(d(rng)); - } -} - -Y_CPU_BENCHMARK(UtilNormal, p) { - TFastRng<ui64> rng(Seed()); - - for (auto i : xrange<size_t>(0, p.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(NormalDistribution<double>(rng, 1.0, 0.0)); - } -} + +// integer part +Y_CPU_BENCHMARK(mt19937_32, p) { + std::mt19937 mt; + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + + Y_DO_NOT_OPTIMIZE_AWAY(mt()); + } +} + +Y_CPU_BENCHMARK(mt19937_64, p) { + std::mt19937_64 mt; + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + + Y_DO_NOT_OPTIMIZE_AWAY(mt()); + } +} + +Y_CPU_BENCHMARK(Mersenne32_GenRand, p) { + TMersenne<ui32> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); + } +} + +Y_CPU_BENCHMARK(Mersenne64_GenRand, p) { + TMersenne<ui64> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); + } +} + +Y_CPU_BENCHMARK(Fast32_GenRand, p) { + TFastRng<ui32> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); + } +} + +Y_CPU_BENCHMARK(Fast64_GenRand, p) { + TFastRng<ui64> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRand()); + } +} + +Y_CPU_BENCHMARK(StlNormal, p) { + TFastRng<ui64> rng(Seed()); + std::normal_distribution<double> d(1.0, 0.0); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(d(rng)); + } +} + +Y_CPU_BENCHMARK(UtilNormal, p) { + TFastRng<ui64> rng(Seed()); + + for (auto i : xrange<size_t>(0, p.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(NormalDistribution<double>(rng, 1.0, 0.0)); + } +} |