Created
December 22, 2013 22:57
-
-
Save komiga/8089447 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
#include <bitset> | |
#include <vector> | |
#include <chrono> | |
#include <iostream> | |
using namespace std::chrono; | |
using hrc = std::chrono::high_resolution_clock; | |
template<class T> | |
void f( | |
T& s, | |
unsigned const NN, | |
unsigned const RR | |
) noexcept { | |
auto t = hrc::now(); | |
for (unsigned x = 0; x < RR; ++x) { | |
bool const b = s[x % NN]; | |
(void)b; | |
s[x % NN] = true; | |
} | |
std::cout | |
<< duration_cast<milliseconds>(hrc::now() - t).count() | |
<< " ms\n" | |
; | |
} | |
signed | |
main() { | |
static unsigned const | |
N = 5e6, | |
R = 3e7 | |
; | |
std::bitset<N> bs; | |
f(bs, N, R); | |
std::vector<bool> v(N); | |
f(v, N, R); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment