Last active
February 6, 2022 11:10
-
-
Save theanalyst/b0b14242be5e7d1c49508610ced24cad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
022-02-05T20:01:21+01:00 | |
Running ./src/randgen | |
Run on (8 X 24.1218 MHz CPU s) | |
CPU Caches: | |
L1 Data 64 KiB (x8) | |
L1 Instruction 128 KiB (x8) | |
L2 Unified 4096 KiB (x2) | |
Load Average: 1.65, 1.91, 2.07 | |
---------------------------------------------------------------------------- | |
Benchmark Time CPU Iterations | |
---------------------------------------------------------------------------- | |
BM_uint32_low_threshold/8 1.83 ns 1.83 ns 360919623 | |
BM_uint32_low_threshold/64 13.1 ns 13.1 ns 53441642 | |
BM_uint32_low_threshold/512 107 ns 107 ns 6562541 | |
BM_uint32_low_threshold/4096 821 ns 821 ns 852017 | |
BM_uint32_low_threshold/32768 6540 ns 6540 ns 106877 | |
BM_uint32_low_threshold/262144 52366 ns 52366 ns 13339 | |
BM_uint32_low_threshold/2097152 425863 ns 425862 ns 1643 | |
BM_uint32_low_threshold/16777216 3376130 ns 3376130 ns 208 | |
BM_uint32_mid_threshold/8 1.63 ns 1.63 ns 428456882 | |
BM_uint32_mid_threshold/64 10.5 ns 10.5 ns 66491888 | |
BM_uint32_mid_threshold/512 86.2 ns 86.2 ns 8119143 | |
BM_uint32_mid_threshold/4096 662 ns 662 ns 1050200 | |
BM_uint32_mid_threshold/32768 5254 ns 5254 ns 132885 | |
BM_uint32_mid_threshold/262144 41838 ns 41838 ns 16737 | |
BM_uint32_mid_threshold/2097152 348465 ns 348465 ns 2006 | |
BM_uint32_mid_threshold/16777216 2735681 ns 2735684 ns 256 | |
BM_uint32_high_threshold/8 1.63 ns 1.63 ns 428171220 | |
BM_uint32_high_threshold/64 10.5 ns 10.5 ns 66571564 | |
BM_uint32_high_threshold/512 87.6 ns 87.6 ns 8092860 | |
BM_uint32_high_threshold/4096 662 ns 662 ns 1054503 | |
BM_uint32_high_threshold/32768 5250 ns 5250 ns 133060 | |
BM_uint32_high_threshold/262144 41845 ns 41844 ns 16733 | |
BM_uint32_high_threshold/2097152 343411 ns 343411 ns 2037 | |
BM_uint32_high_threshold/16777216 2734923 ns 2734925 ns 255 | |
BM_uint64_low_threshold/8 1.47 ns 1.47 ns 473802127 | |
BM_uint64_low_threshold/64 7.90 ns 7.90 ns 88438554 | |
BM_uint64_low_threshold/512 68.9 ns 68.9 ns 10152432 | |
BM_uint64_low_threshold/4096 638 ns 638 ns 1094468 | |
BM_uint64_low_threshold/32768 5211 ns 5211 ns 134053 | |
BM_uint64_low_threshold/262144 41792 ns 41791 ns 16752 | |
BM_uint64_low_threshold/2097152 342561 ns 342560 ns 2034 | |
BM_uint64_low_threshold/16777216 2724697 ns 2724697 ns 254 | |
BM_uint64_mid_threshold/8 1.32 ns 1.32 ns 532165610 | |
BM_uint64_mid_threshold/64 6.35 ns 6.35 ns 110330044 | |
BM_uint64_mid_threshold/512 60.3 ns 60.3 ns 11582309 | |
BM_uint64_mid_threshold/4096 628 ns 628 ns 1113586 | |
BM_uint64_mid_threshold/32768 5201 ns 5201 ns 133917 | |
BM_uint64_mid_threshold/262144 41761 ns 41761 ns 16756 | |
BM_uint64_mid_threshold/2097152 343010 ns 343010 ns 2045 | |
BM_uint64_mid_threshold/16777216 2721280 ns 2721284 ns 257 | |
BM_uint64_high_threshold/8 1.32 ns 1.32 ns 532210117 | |
BM_uint64_high_threshold/64 6.34 ns 6.34 ns 110366575 | |
BM_uint64_high_threshold/512 60.3 ns 60.3 ns 11571587 | |
BM_uint64_high_threshold/4096 628 ns 628 ns 1113267 | |
BM_uint64_high_threshold/32768 5203 ns 5203 ns 134105 | |
BM_uint64_high_threshold/262144 41753 ns 41752 ns 16752 | |
BM_uint64_high_threshold/2097152 342691 ns 342692 ns 2032 | |
BM_uint64_high_threshold/16777216 2718238 ns 2718240 ns 258 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <random> | |
#include "benchmark/benchmark.h" | |
#include <iostream> | |
namespace { | |
std::random_device rd; | |
std::mt19937 generator(rd()); | |
} | |
template <typename T> | |
auto generate_vec(size_t sz, T start=0, | |
T end = std::numeric_limits<T>::max() - 1) | |
{ | |
std::vector<T> v; | |
v.resize(sz); | |
std::uniform_int_distribution<T> distrib(start, end); | |
std::generate(v.begin(), v.end(), [start, end]() { | |
return distrib(generator); | |
}); | |
return v; | |
} | |
template <typename C> | |
size_t count(const C& cont, | |
typename C::value_type threshold) | |
{ | |
size_t n = 0; | |
for (const auto& it: cont) { | |
n += bool( it > threshold ); | |
} | |
return n; | |
} | |
static void BM_uint32_low_threshold(benchmark::State& state) | |
{ | |
auto sz = state.range(0); | |
auto vec = generate_vec<uint32_t>(state.range(0)); | |
for (auto _ : state) { | |
benchmark::DoNotOptimize(count(vec, 0)); | |
} | |
} | |
static void BM_uint32_mid_threshold(benchmark::State& state) | |
{ | |
auto sz = state.range(0); | |
auto vec = generate_vec<uint32_t>(state.range(0)); | |
for (auto _ : state) { | |
benchmark::DoNotOptimize(count(vec, 1<<31)); | |
} | |
} | |
static void BM_uint32_high_threshold(benchmark::State& state) | |
{ | |
auto sz = state.range(0); | |
auto vec = generate_vec<uint32_t>(state.range(0)); | |
for (auto _ : state) { | |
benchmark::DoNotOptimize(count(vec, std::numeric_limits<uint32_t>::max() - 1)); | |
} | |
} | |
static void BM_uint64_low_threshold(benchmark::State& state) | |
{ | |
auto sz = state.range(0); | |
auto vec = generate_vec<uint64_t>(state.range(0)); | |
for (auto _ : state) { | |
benchmark::DoNotOptimize(count(vec, 0)); | |
} | |
} | |
static void BM_uint64_mid_threshold(benchmark::State& state) | |
{ | |
auto sz = state.range(0); | |
auto vec = generate_vec<uint64_t>(state.range(0)); | |
for (auto _ : state) { | |
benchmark::DoNotOptimize(count(vec, 1ULL<<63)); | |
} | |
} | |
static void BM_uint64_high_threshold(benchmark::State& state) | |
{ | |
auto sz = state.range(0); | |
auto vec = generate_vec<uint64_t>(state.range(0)); | |
for (auto _ : state) { | |
benchmark::DoNotOptimize(count(vec, std::numeric_limits<uint64_t>::max() - 1)); | |
} | |
} | |
int64_t start = 8; | |
int64_t end = 1<<24UL; | |
BENCHMARK(BM_uint32_low_threshold)->Range(start, end); | |
BENCHMARK(BM_uint32_mid_threshold)->Range(start, end); | |
BENCHMARK(BM_uint32_high_threshold)->Range(start, end); | |
BENCHMARK(BM_uint64_low_threshold)->Range(start, end); | |
BENCHMARK(BM_uint64_mid_threshold)->Range(start, end); | |
BENCHMARK(BM_uint64_high_threshold)->Range(start, end); | |
BENCHMARK_MAIN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment