Skip to content

Commit 74af7a7

Browse files
test ci
1 parent 5fa0322 commit 74af7a7

File tree

5 files changed

+76
-54
lines changed

5 files changed

+76
-54
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,6 @@ jobs:
4040
name: test_results
4141
path: ${{runner.workspace}}/core/build-tests/test/test-results/**/*.json
4242

43-
windows-build:
44-
strategy:
45-
matrix:
46-
codspeed-mode: ["off", "walltime"]
47-
runs-on: windows-latest
48-
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v3
51-
52-
- name: Cache build
53-
uses: actions/cache@v3
54-
with:
55-
path: examples/google_benchmark_cmake/build
56-
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt') }}
57-
58-
- name: Create build directory
59-
run: |
60-
if (-not (Test-Path examples\google_benchmark_cmake\build)) {
61-
mkdir examples\google_benchmark_cmake\build
62-
}
63-
shell: pwsh
64-
65-
- name: Build benchmark example
66-
run: |
67-
cd examples\google_benchmark_cmake\build
68-
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
69-
cmake --build . --config Release
70-
shell: pwsh
71-
7243
cmake-integration-tests:
7344
strategy:
7445
matrix:
@@ -140,3 +111,55 @@ jobs:
140111
with:
141112
run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
142113
token: ${{ secrets.CODSPEED_TOKEN }}
114+
115+
windows-cmake-build:
116+
strategy:
117+
matrix:
118+
codspeed-mode: ["off", "walltime"]
119+
runs-on: windows-latest
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v3
123+
124+
- name: Cache build
125+
uses: actions/cache@v3
126+
with:
127+
path: examples/google_benchmark_cmake/build
128+
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt') }}
129+
130+
- name: Create build directory
131+
run: |
132+
if (-not (Test-Path examples\google_benchmark_cmake\build)) {
133+
mkdir examples\google_benchmark_cmake\build
134+
}
135+
shell: pwsh
136+
137+
- name: Build benchmark example
138+
run: |
139+
cd examples\google_benchmark_cmake\build
140+
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
141+
cmake --build . --config Release
142+
shell: pwsh
143+
144+
windows-bazel-build:
145+
strategy:
146+
matrix:
147+
codspeed-mode: ["off", "walltime"]
148+
runs-on: windows-latest
149+
steps:
150+
- uses: actions/checkout@v4
151+
152+
- name: Set up Bazel
153+
uses: bazel-contrib/[email protected]
154+
with:
155+
# Avoid downloading Bazel every time.
156+
bazelisk-cache: true
157+
# Store build cache per workflow.
158+
disk-cache: ${{ github.workflow }}
159+
# Share repository cache between workflows.
160+
repository-cache: true
161+
162+
- name: Build benchmark example
163+
run: |
164+
bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
165+
shell: pwsh

core/include/codspeed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CodSpeed {
3434
struct RawWalltimeBenchmark {
3535
std::string name;
3636
std::string uri;
37-
int64_t iter_per_round;
37+
uint64_t iter_per_round;
3838
double mean_ns;
3939
double median_ns;
4040
double stdev_ns;

core/src/walltime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct BenchmarkStats {
3232
double total_time;
3333
uint64_t iqr_outlier_rounds;
3434
uint64_t stdev_outlier_rounds;
35-
int64_t iter_per_round;
35+
uint64_t iter_per_round;
3636
uint64_t warmup_iters;
3737
};
3838

core/src/workspace.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace codspeed {
99

1010
std::string safe_getenv(const char* var_name) {
1111
#ifdef _WIN32
12+
// On Windows, use _dupenv_s instead of std::getenv for thread safety
13+
// and to avoid issues with buffer ownership
1214
char* value;
1315
size_t len;
1416
errno_t err = _dupenv_s(&value, &len, var_name);

google_benchmark/include/benchmark/benchmark.h

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
185185

186186
#ifdef CODSPEED_ENABLED
187187
#include <codspeed.h>
188-
#include <measurement.hpp>
189188

190189
#include <filesystem>
191-
#endif // CODSPEED_ENABLED
190+
#include <measurement.hpp>
191+
#endif // CODSPEED_ENABLED
192192

193193
#if defined(_MSC_VER)
194194
#include <intrin.h> // for _ReadWriteBarrier
@@ -947,7 +947,7 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State {
947947
public:
948948
const IterationCount max_iterations;
949949
#ifdef CODSPEED_INSTRUMENTATION
950-
codspeed::CodSpeed *codspeed_;
950+
codspeed::CodSpeed* codspeed_;
951951
#endif
952952

953953
private:
@@ -970,11 +970,11 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State {
970970
internal::ThreadTimer* timer, internal::ThreadManager* manager,
971971
internal::PerfCountersMeasurement* perf_counters_measurement,
972972
ProfilerManager* profiler_manager
973-
#ifdef CODSPEED_INSTRUMENTATION
973+
#ifdef CODSPEED_INSTRUMENTATION
974974
,
975-
codspeed::CodSpeed *codspeed = NULL
976-
#endif
977-
);
975+
codspeed::CodSpeed* codspeed = NULL
976+
#endif
977+
);
978978

979979
void StartKeepRunning();
980980
// Implementation of KeepRunning() and KeepRunningBatch().
@@ -1460,26 +1460,23 @@ class Fixture : public internal::Benchmark {
14601460
BaseClass##_##Method##_Benchmark
14611461

14621462
#ifdef _MSC_VER
1463-
#define BENCHMARK_PRIVATE_DECLARE(n) \
1464-
/* NOLINTNEXTLINE(misc-use-anonymous-namespace) */ \
1465-
static ::benchmark::internal::Benchmark const* const BENCHMARK_PRIVATE_NAME( \
1466-
n)
1463+
#define BENCHMARK_PRIVATE_DECLARE(n) \
1464+
/* NOLINTNEXTLINE(misc-use-anonymous-namespace) */ \
1465+
static ::benchmark::internal::Benchmark const* const BENCHMARK_PRIVATE_NAME(n)
14671466
#else
1468-
#define BENCHMARK_PRIVATE_DECLARE(n) \
1469-
/* NOLINTNEXTLINE(misc-use-anonymous-namespace) */ \
1470-
static ::benchmark::internal::Benchmark const* const BENCHMARK_PRIVATE_NAME( \
1471-
n) [[maybe_unused]]
1467+
#define BENCHMARK_PRIVATE_DECLARE(n) \
1468+
/* NOLINTNEXTLINE(misc-use-anonymous-namespace) */ \
1469+
static ::benchmark::internal::Benchmark const* const BENCHMARK_PRIVATE_NAME(n)
14721470
#endif
14731471

14741472
#ifdef CODSPEED_ENABLED
1475-
#define CUR_FILE \
1476-
codspeed::get_path_relative_to_workspace(__FILE__) + "::"
1473+
#define CUR_FILE codspeed::get_path_relative_to_workspace(__FILE__) + "::"
14771474
#ifdef _MSC_VER
1478-
#define NAMESPACE std::string("")
1479-
#else
1475+
// TODO: __PRETTY_FUNCTION__ is not available in MSVC and we dont support
1476+
#define __PRETTY_FUNCTION__ "unsupported"
1477+
#endif
14801478
#define NAMESPACE \
14811479
(([]() { return codspeed::extract_lambda_namespace(__PRETTY_FUNCTION__); })())
1482-
#endif
14831480
#define STATIC_NAMESPACE_STRING(name) static std::string name = NAMESPACE;
14841481

14851482
#define FILE_AND_NAMESPACE CUR_FILE + NAMESPACE
@@ -1618,12 +1615,12 @@ class Fixture : public internal::Benchmark {
16181615
#ifdef CODSPEED_ENABLED
16191616

16201617
#define BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \
1621-
STATIC_NAMESPACE_STRING(ns_##BaseClass##_##Method); \
1618+
STATIC_NAMESPACE_STRING(ns_##BaseClass##_##Method); \
16221619
class BaseClass##_##Method##_Benchmark : public BaseClass { \
16231620
public: \
16241621
BaseClass##_##Method##_Benchmark() { \
16251622
this->SetName(CUR_FILE + ns_##BaseClass##_##Method + \
1626-
#Method "[" #BaseClass "]"); \
1623+
#Method "[" #BaseClass "]"); \
16271624
} \
16281625
\
16291626
protected: \
@@ -1669,7 +1666,7 @@ class Fixture : public internal::Benchmark {
16691666
void BenchmarkCase(::benchmark::State&) override; \
16701667
};
16711668

1672-
#else // CODSPEED_ENABLED undefined:
1669+
#else // CODSPEED_ENABLED undefined:
16731670

16741671
#define BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \
16751672
class BaseClass##_##Method##_Benchmark : public BaseClass { \

0 commit comments

Comments
 (0)