Skip to content

Commit 5e9aec6

Browse files
fix(google_benchmark): get pid instead of thread id
1 parent 1dda619 commit 5e9aec6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

core/src/walltime.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#include <numeric>
99
#include <sstream>
1010
#include <string>
11-
#include <thread>
11+
#ifdef _WIN32
12+
#include <process.h>
13+
#else
14+
#include <unistd.h>
15+
#endif
1216
#include <vector>
1317

1418
const double IQR_OUTLIER_FACTOR = 1.5;
@@ -105,7 +109,11 @@ void write_codspeed_benchmarks_to_json(
105109

106110
std::string creator_name = "codspeed-cpp";
107111
std::string creator_version = CODSPEED_VERSION;
108-
std::thread::id creator_pid = std::this_thread::get_id();
112+
#ifdef _WIN32
113+
pid_t creator_pid = _getpid();
114+
#else
115+
pid_t creator_pid = getpid();
116+
#endif
109117
std::string instrument_type = "walltime";
110118

111119
oss << "{\n";

0 commit comments

Comments
 (0)