Created
August 29, 2018 07:18
-
-
Save BillyONeal/6e3cf7395e948262e9d082b6bcce9939 to your computer and use it in GitHub Desktop.
Bitset Bench
This file contains hidden or 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 <bitset> | |
#include <benchmark/benchmark.h> | |
const char bitText[] = | |
"0100010100111101100001010100101010011101011110001000101101101001" | |
"0110011011101100001101001111111101111011101000111000100101011110" | |
"0001010000010000111001101001101001110111000011100101011100101010" | |
"0000010110110110110010001111011000100000011000000000001010000011" | |
"1101010111000001011011010111010100001110110111111100110000101111" | |
"1010100100000011011000001011110000000111111001000010010100110000" | |
"1110011000101010110110011110101110101010000110101011110101010001" | |
"0100010010111100111100111001101101110111000100100010001110101000" | |
"1101111100111111110101101000000100111101101100100001010101111010" | |
"1100011000101101010010010110010010011000101011111100011110011101" | |
"1010101011101110101010011111101101101100101000111100000001001110" | |
"0100011001010101010011100100001100011011111010101011101110110011" | |
"0101110110111000111010110011001001110101011101000101100100111001" | |
"1111100100001001111110010110110101110111101101010110011001010010" | |
"1001010101110100000100011010010110010111010100110111110010111100" | |
"1100000010110100101100111110111010000001100000010011110011011001" | |
"1000101100101010001101010111011101101001100110000001010010001011" | |
"0001010000001001101010010110001100011001010000010100100110011100" | |
"1100010001110111100000011111110010010100000000011101110101000010" | |
"0011100000111110000101000011010001011101010001100001001110011110" | |
"1001010100111010110101110000110110101011011000110001001101110100" | |
"0010011000101110100110001011110000101110110110100101010010110110" | |
"0101111110101101110100000000110110000100101010011000110010110000" | |
"0010001001111010100011100000010000110010000010010101101101111111" | |
"1010010101000011100101000010000001010100100001110011011010000010" | |
"1100010000101010111111110110110011011010101110100111111111011100" | |
"1111000100000101111101100000001100011101111100011011110000111100" | |
"0101101100111010111100010111110010111011011000010111100010000010" | |
"0000001101011101100111111010011000001000111010101101001110100001" | |
"1100001001010010110110000010110110100101111111011110011110100101" | |
"0001101011001010101001110011011110100001111101111111010000100111" | |
"0010111000001100011111111000011101000100110101101000101111100010"; | |
template<size_t bits> | |
void test_bitset(benchmark::State& state) { | |
for (auto&& _ : state) { | |
(void)_; | |
std::bitset<bits> madeBits(bitText, bits); | |
benchmark::DoNotOptimize(madeBits); | |
} | |
} | |
BENCHMARK_TEMPLATE1(test_bitset, 8); | |
BENCHMARK_TEMPLATE1(test_bitset, 16); | |
BENCHMARK_TEMPLATE1(test_bitset, 32); | |
BENCHMARK_TEMPLATE1(test_bitset, 64); | |
BENCHMARK_TEMPLATE1(test_bitset, 128); | |
BENCHMARK_TEMPLATE1(test_bitset, 256); | |
BENCHMARK_TEMPLATE1(test_bitset, 512); | |
BENCHMARK_TEMPLATE1(test_bitset, 2048); | |
BENCHMARK_MAIN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment