serge-sans-paille / frozen

a header-only, constexpr alternative to gperf for C++14 users
Apache License 2.0
1.26k stars 102 forks source link

Benchmarks on larger sets #60

Open ghost opened 5 years ago

ghost commented 5 years ago

Seems like having int array of 32 numbers makes std::array look great vs frozen. However once we go for 64 numbers etc frozen looks way better. I guess it'd be interesting to improve benchmarks to show perfect hash potential on larger sets.

ghost commented 5 years ago

GCC 8.1.0 unmodified benchmark

2018-11-20 14:43:47
Running ./benchmarks/frozen.benchmark
Run on (8 X 3800 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 256K (x4)
  L3 Unified 8192K (x1)
Load Average: 0.54, 0.64, 1.98
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
------------------------------------------------------------------
Benchmark                           Time           CPU Iterations
------------------------------------------------------------------
BM_IntInFzSet                      91 ns         91 ns    7707237
BM_IntInStdSet                    179 ns        179 ns    3910143
BM_IntInStdArray                   49 ns         49 ns   14465849
BM_IntNotInFzSet                   91 ns         91 ns    7658368
BM_IntNotInStdSet                 137 ns        137 ns    5083290
BM_IntNotInStdArray                27 ns         27 ns   25582279

GCC 8.1.0 Keywords set increased to 64 integers

$ ./benchmarks/frozen.benchmark 
2018-11-20 14:40:01
Running ./benchmarks/frozen.benchmark
Run on (8 X 3800 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 256K (x4)
  L3 Unified 8192K (x1)
Load Average: 0.15, 0.69, 2.37
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
------------------------------------------------------------------
Benchmark                           Time           CPU Iterations
------------------------------------------------------------------
BM_IntInFzSet                     213 ns        213 ns    3298455
BM_IntInStdSet                    391 ns        391 ns    1808459
BM_IntInStdArray                  748 ns        747 ns     925253
BM_IntNotInFzSet                  106 ns        106 ns    6576485
BM_IntNotInStdSet                 137 ns        137 ns    5061951
BM_IntNotInStdArray               702 ns        702 ns     982936
serge-sans-paille commented 5 years ago

@divaykin I think both results are interesting. You can propose a PR for an extra set of benchmark with larger dataset.