edit
[c11concurrency-benchmarks.git] / src / utils.cpp
1 #include <utils.h>
2
3 long long iris::get_current_time_in_us() {
4     struct timeval v;
5     gettimeofday(&v, nullptr);
6     return (long long)v.tv_sec * 1000000 + v.tv_usec;
7 }
8
9
10 int iris::round_up_to_next_multiple_of_2(int n) {
11     int bits = 0, ones = 0, oldn = n;
12     while(n) {
13         if (n & 1)
14             ++ones;
15         ++bits;
16         n >>= 1;
17     }
18
19     if (ones == 1) // already a multiple of 2
20         return oldn;
21     return 1 << bits;
22 }