Skip to content

Commit 5427916

Browse files
committed
fix: only inline macros
1 parent 035e4bc commit 5427916

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

.vscode/settings.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"cmake.sourceDirectory": "/workspaces/codspeed-cpp/picobench"
3-
}
2+
"cmake.sourceDirectory": "/workspaces/codspeed-cpp/picobench",
3+
"files.associations": {
4+
"*.ejs": "html",
5+
"string": "cpp",
6+
"chrono": "cpp",
7+
"text_encoding": "cpp",
8+
"typeinfo": "cpp"
9+
}
10+
}

core/include/codspeed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class CodSpeed {
1818
// Member functions
1919
void push_group(const std::string &group);
2020
void pop_group();
21-
void start_benchmark(const std::string &name);
22-
void end_benchmark();
21+
void start_benchmark(const std::string &name) __attribute__((noinline));
22+
void end_benchmark() __attribute__((noinline));
2323

2424
private:
2525
// Private constructor to prevent direct instantiation

core/include/measurement.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,15 @@ inline void measurement_set_metadata() {
4646
}
4747

4848
__attribute__((always_inline)) inline void measurement_start() {
49-
instrument_hooks_start_benchmark(get_hooks());
50-
5149
CALLGRIND_ZERO_STATS;
5250
CALLGRIND_START_INSTRUMENTATION;
5351
}
5452

5553
__attribute__((always_inline)) inline void measurement_stop() {
5654
CALLGRIND_STOP_INSTRUMENTATION;
57-
58-
instrument_hooks_stop_benchmark(get_hooks());
5955
};
6056

61-
__attribute__((noinline)) inline void measurement_set_executed(
62-
const std::string& name) {
57+
inline void measurement_set_executed(const std::string& name) {
6358
#ifdef _WIN32
6459
auto current_pid = _getpid();
6560
#else

core/src/codspeed.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ void CodSpeed::pop_group() {
6969
}
7070
}
7171

72-
void CodSpeed::start_benchmark(const std::string &name) {
72+
__attribute__((noinline)) void CodSpeed::start_benchmark(
73+
const std::string &name) {
7374
std::string uri = name;
7475

7576
uri = sanitize_bench_args(uri);
@@ -82,9 +83,11 @@ void CodSpeed::start_benchmark(const std::string &name) {
8283
}
8384

8485
current_benchmark = uri;
86+
instrument_hooks_start_benchmark(get_hooks());
8587
}
8688

87-
void CodSpeed::end_benchmark() {
89+
__attribute__((noinline)) void CodSpeed::end_benchmark() {
90+
instrument_hooks_stop_benchmark(get_hooks());
8891
measurement_set_executed(current_benchmark);
8992
benchmarked.push_back(current_benchmark);
9093
std::string action_str = is_instrumented ? "Measured" : "Checked";

0 commit comments

Comments
 (0)