Skip to content

Commit ec0c108

Browse files
committed
feat: add instrument-hooks library
1 parent 3e44949 commit ec0c108

File tree

13 files changed

+147
-7321
lines changed

13 files changed

+147
-7321
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
steps:
2121
- name: Checkout code
2222
uses: actions/checkout@v3
23+
with:
24+
submodules: "recursive"
2325

2426
- name: Cache build
2527
uses: actions/cache@v3
@@ -62,6 +64,8 @@ jobs:
6264
steps:
6365
- name: Checkout code
6466
uses: actions/checkout@v3
67+
with:
68+
submodules: "recursive"
6569

6670
- name: Cache build
6771
uses: actions/cache@v3
@@ -81,6 +85,8 @@ jobs:
8185
- name: Run the benchmarks
8286
uses: CodSpeedHQ/action@main
8387
if: matrix.codspeed-mode != 'off'
88+
env:
89+
CODSPEED_PERF_ENABLED: true
8490
with:
8591
run: examples/google_benchmark_cmake/build/benchmark_example
8692
token: ${{ secrets.CODSPEED_TOKEN }}
@@ -98,6 +104,8 @@ jobs:
98104
runs-on: ${{ matrix.runner }}
99105
steps:
100106
- uses: actions/checkout@v4
107+
with:
108+
submodules: "recursive"
101109

102110
- name: Set up Bazel
103111
uses: bazel-contrib/[email protected]
@@ -116,6 +124,8 @@ jobs:
116124
- name: Run the benchmarks
117125
uses: CodSpeedHQ/action@main
118126
if: matrix.codspeed-mode != 'off'
127+
env:
128+
CODSPEED_PERF_ENABLED: true
119129
with:
120130
run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
121131
token: ${{ secrets.CODSPEED_TOKEN }}
@@ -128,6 +138,8 @@ jobs:
128138
steps:
129139
- name: Checkout code
130140
uses: actions/checkout@v3
141+
with:
142+
submodules: "recursive"
131143

132144
- name: Cache build
133145
uses: actions/cache@v3
@@ -156,6 +168,8 @@ jobs:
156168
runs-on: windows-latest
157169
steps:
158170
- uses: actions/checkout@v4
171+
with:
172+
submodules: "recursive"
159173

160174
- name: Set up Bazel
161175
uses: bazel-contrib/[email protected]

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "core/instrument-hooks"]
2+
path = core/instrument-hooks
3+
url = https://github.com/CodSpeedHQ/instrument-hooks

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3-
exclude: '^(google_benchmark/.*|core/instrument-hooks/.*|.*/build/.*|build/.*|core/include/valgrind\.h|core/include/callgrind\.h)'
3+
exclude: '^(google_benchmark/.*|.*/build/.*|build/.*|core/include/valgrind\.h|core/include/callgrind\.h)'
44
files: ^(core|examples)/.*$
55

66
repos:

MODULE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
bazel_dep(name = "rules_cc", version = "0.0.17")
2+
bazel_dep(name = "instrument_hooks", version = "1.0.0")
3+
4+
git_override(
5+
module_name = "instrument_hooks",
6+
commit = "42ed74076c697c2f06c5ac81a84ccee983d7f140",
7+
remote = "https://github.com/CodSpeedHQ/instrument-hooks",
8+
)

core/BUILD

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,33 @@ config_setting(
88
constraint_values = ["@platforms//os:windows"],
99
)
1010

11+
# Instrument-hooks library with warning suppressions
12+
cc_library(
13+
name = "instrument_hooks",
14+
srcs = ["instrument-hooks/dist/core.c"],
15+
hdrs = glob(["instrument-hooks/includes/*.h"]),
16+
includes = ["instrument-hooks/includes"],
17+
copts = select({
18+
":windows": [
19+
"/wd4101", # unreferenced local variable (equivalent to -Wno-unused-variable)
20+
"/wd4189", # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
21+
"/wd4100", # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
22+
"/wd4245", # signed/unsigned mismatch
23+
"/wd4132", # const object should be initialized
24+
"/wd4146", # unary minus operator applied to unsigned type
25+
],
26+
"//conditions:default": [
27+
"-Wno-maybe-uninitialized",
28+
"-Wno-unused-variable",
29+
"-Wno-unused-parameter",
30+
"-Wno-unused-but-set-variable",
31+
"-Wno-type-limits",
32+
],
33+
}),
34+
visibility = ["//visibility:public"],
35+
)
36+
37+
1138
# Define the codspeed library
1239
cc_library(
1340
name = "codspeed",
@@ -25,6 +52,7 @@ cc_library(
2552
":walltime_mode": ["CODSPEED_ENABLED", "CODSPEED_WALLTIME"],
2653
"//conditions:default": [],
2754
}),
55+
deps = [":instrument_hooks"],
2856
visibility = ["//visibility:public"],
2957
)
3058

core/CMakeLists.txt

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
set(CODSPEED_VERSION 1.2.0)
44

5-
project(codspeed VERSION ${CODSPEED_VERSION} LANGUAGES CXX)
5+
project(codspeed VERSION ${CODSPEED_VERSION} LANGUAGES CXX C)
66

77
# Specify the C++ standard
88
set(CMAKE_CXX_STANDARD 17)
@@ -11,22 +11,66 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1111
# Add the include directory
1212
include_directories(include)
1313

14-
# Add the library
14+
# Add the instrument_hooks library
15+
add_library(
16+
instrument_hooks
17+
STATIC
18+
instrument-hooks/dist/core.c
19+
)
20+
21+
target_include_directories(
22+
instrument_hooks
23+
PUBLIC
24+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/instrument-hooks/includes>
25+
$<INSTALL_INTERFACE:includes>
26+
)
27+
28+
# Suppress warnings for the instrument_hooks library
29+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
30+
target_compile_options(
31+
instrument_hooks
32+
PRIVATE
33+
-Wno-maybe-uninitialized
34+
-Wno-unused-variable
35+
-Wno-unused-parameter
36+
-Wno-unused-but-set-variable
37+
-Wno-type-limits
38+
)
39+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
40+
target_compile_options(
41+
instrument_hooks
42+
PRIVATE
43+
/wd4101 # unreferenced local variable (equivalent to -Wno-unused-variable)
44+
/wd4189 # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
45+
/wd4100 # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
46+
/wd4245 # signed/unsigned mismatch
47+
/wd4132 # const object should be initialized
48+
/wd4146 # unary minus operator applied to unsigned type
49+
)
50+
endif()
51+
52+
53+
# Add the main library
1554
add_library(
1655
codspeed
1756
src/codspeed.cpp
57+
src/measurement.cpp
1858
src/walltime.cpp
1959
src/uri.cpp
2060
src/workspace.cpp
2161
)
2262

63+
# Link instrument_hooks to codspeed
64+
target_link_libraries(codspeed PRIVATE instrument_hooks)
65+
2366
# Version
2467
add_compile_definitions(CODSPEED_VERSION="${CODSPEED_VERSION}")
2568

2669
# Specify the include directories for users of the library
2770
target_include_directories(
2871
codspeed
2972
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
73+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/instrument-hooks/includes>
3074
)
3175

3276
# Disable valgrind compilation errors
@@ -116,7 +160,7 @@ install(
116160
)
117161

118162
install(
119-
TARGETS codspeed
163+
TARGETS codspeed instrument_hooks
120164
EXPORT codspeed-targets
121165
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
122166
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

core/include/callgrind.h

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)