|
31 | 31 | // VERSION HISTORY |
32 | 32 | // |
33 | 33 | // 2.9.0 (2026-04-30) * Completely drop binding benchmarks to a single core |
| 34 | +// * Drop custom Windows clock and just use |
| 35 | +// std::high_resolution_clock everywhere |
34 | 36 | // 2.8.0 (2025-12-15) Switch to SemVer to appease certain package managers |
35 | 37 | // |
36 | 38 | // 2.08 (2025-04-04) Internal. This file was not affected |
|
157 | 159 | namespace PICOBENCH_NAMESPACE |
158 | 160 | { |
159 | 161 |
|
160 | | -#if defined(_MSC_VER) || defined(__MINGW32__) || defined(PICOBENCH_TEST) |
| 162 | +#if defined(PICOBENCH_TEST) |
161 | 163 | struct high_res_clock |
162 | 164 | { |
163 | 165 | typedef long long rep; |
@@ -376,11 +378,6 @@ class global_registry |
376 | 378 | #include <cstdlib> |
377 | 379 | #include <algorithm> |
378 | 380 |
|
379 | | -#if defined(_WIN32) |
380 | | -# define WIN32_LEAN_AND_MEAN |
381 | | -# include <Windows.h> |
382 | | -#endif |
383 | | - |
384 | 381 | namespace PICOBENCH_NAMESPACE |
385 | 382 | { |
386 | 383 |
|
@@ -956,28 +953,6 @@ class runner : public registry |
956 | 953 | b->_istate = b->_states.begin(); |
957 | 954 | } |
958 | 955 |
|
959 | | -#if !defined(PICOBENCH_DONT_BIND_TO_ONE_CORE) |
960 | | - // set thread affinity to first cpu |
961 | | - // so the high resolution clock doesn't miss cycles |
962 | | - { |
963 | | -#if defined(_WIN32) |
964 | | - SetThreadAffinityMask(GetCurrentThread(), 1); |
965 | | -#elif defined(__APPLE__) |
966 | | - thread_affinity_policy_data_t policy = {0}; |
967 | | - thread_policy_set( |
968 | | - pthread_mach_thread_np(pthread_self()), |
969 | | - THREAD_AFFINITY_POLICY, |
970 | | - (thread_policy_t)&policy, 1); |
971 | | -#else |
972 | | - cpu_set_t cpuset; |
973 | | - CPU_ZERO(&cpuset); |
974 | | - CPU_SET(0, &cpuset); |
975 | | - |
976 | | - sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); |
977 | | -#endif |
978 | | - } |
979 | | -#endif |
980 | | - |
981 | 956 | // we run a random benchmark from it incrementing _istate for each |
982 | 957 | // when _istate reaches _states.end(), we erase the benchmark |
983 | 958 | // when the vector becomes empty, we're done |
@@ -1490,22 +1465,6 @@ int global_registry::set_bench_suite(const char* name) |
1490 | 1465 | return 0; |
1491 | 1466 | } |
1492 | 1467 |
|
1493 | | -#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(PICOBENCH_TEST) |
1494 | | - |
1495 | | -static const long long high_res_clock_freq = []() -> long long |
1496 | | -{ |
1497 | | - LARGE_INTEGER frequency; |
1498 | | - QueryPerformanceFrequency(&frequency); |
1499 | | - return frequency.QuadPart; |
1500 | | -}(); |
1501 | | - |
1502 | | -high_res_clock::time_point high_res_clock::now() |
1503 | | -{ |
1504 | | - LARGE_INTEGER t; |
1505 | | - QueryPerformanceCounter(&t); |
1506 | | - return time_point(duration((t.QuadPart * rep(period::den)) / high_res_clock_freq)); |
1507 | | -} |
1508 | | -#endif |
1509 | 1468 | } |
1510 | 1469 |
|
1511 | 1470 | #endif |
|
0 commit comments