File tree 11 files changed +211
-0
lines changed
include/codspeed_picobench_compat
include/codspeed_picobench_compat 11 files changed +211
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Prerequisites
2
+ * .d
3
+
4
+ # Compiled Object files
5
+ * .slo
6
+ * .lo
7
+ * .o
8
+ * .obj
9
+
10
+ # Precompiled Headers
11
+ * .gch
12
+ * .pch
13
+
14
+ # Compiled Dynamic libraries
15
+ * .so
16
+ * .dylib
17
+ * .dll
18
+
19
+ # Fortran module files
20
+ * .mod
21
+ * .smod
22
+
23
+ # Compiled Static libraries
24
+ * .lai
25
+ * .la
26
+ * .a
27
+ * .lib
28
+
29
+ # Executables
30
+ * .exe
31
+ * .out
32
+ * .app
33
+
34
+ build /
Original file line number Diff line number Diff line change
1
+ {
2
+ "cmake.sourceDirectory" : " /workspaces/codspeed-cpp/picobench"
3
+ }
Original file line number Diff line number Diff line change
1
+ # codspeed-cpp
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.12)
2
+ include (FetchContent)
3
+
4
+ project (codspeed_google_benchmark_compat VERSION 0.0.0 LANGUAGES CXX)
5
+
6
+ FetchContent_Declare(
7
+ google_benchmark
8
+ GIT_REPOSITORY https://github.com/google/benchmark.git
9
+ GIT_TAG 12235e24652fc7f809373e7c11a5f73c5763fc4c # v1.9.0
10
+ )
11
+ FetchContent_MakeAvailable(google_benchmark)
12
+
13
+ add_library (codspeed_picobench_compat)
14
+
Original file line number Diff line number Diff line change
1
+ macro (pb_example name )
2
+ set (tgt picobench-example-${name} )
3
+ add_executable (${tgt} ${ARGN} )
4
+ target_link_libraries (${tgt} codspeed_picobench_compat)
5
+ set_target_properties (${tgt} PROPERTIES FOLDER example)
6
+ add_custom_target (
7
+ picobench-run-example-${name}
8
+ COMMAND ${tgt}
9
+ )
10
+ endmacro ()
11
+
12
+ pb_example(basic basic.cpp)
Original file line number Diff line number Diff line change
1
+ #define PICOBENCH_DEBUG
2
+ #define PICOBENCH_IMPLEMENT_WITH_MAIN
3
+ #include " codspeed_picobench_compat/picobench.hpp"
4
+
5
+ #include < vector>
6
+ #include < deque>
7
+ #include < cstdlib>
8
+
9
+ void rand_vector (picobench::state& s)
10
+ {
11
+ std::vector<int > v;
12
+ for (auto _ : s)
13
+ {
14
+ v.push_back (rand ());
15
+ }
16
+ }
17
+ PICOBENCH (rand_vector);
18
+
19
+ void rand_vector_reserve (picobench::state& s)
20
+ {
21
+ std::vector<int > v;
22
+ v.reserve (s.iterations ());
23
+ for (auto _ : s)
24
+ {
25
+ v.push_back (rand ());
26
+ }
27
+ }
28
+ PICOBENCH (rand_vector_reserve);
29
+
30
+ void rand_deque (picobench::state& s)
31
+ {
32
+ std::deque<int > v;
33
+ for (auto _ : s)
34
+ {
35
+ v.push_back (rand ());
36
+ }
37
+ }
38
+ PICOBENCH (rand_deque);
Original file line number Diff line number Diff line change
1
+ #ifndef CODSPEED_PICOBENCH_COMPAT_HPP_INCLUDED
2
+ #define CODSPEED_PICOBENCH_COMPAT_HPP_INCLUDED
3
+
4
+ #include " picobench/picobench.hpp"
5
+ #include < iostream>
6
+
7
+ // Undefine the original PICOBENCH macro
8
+ // #undef PICOBENCH
9
+
10
+ // Define a new PICOBENCH macro that wraps the original functionality
11
+ #define PICOBENCH2 (func ) \
12
+ do { \
13
+ std::cout << " Registering benchmark for " << #func << std::endl; \
14
+ static auto & I_PICOBENCH_PP_CAT (picobench, PICOBENCH_UNIQUE_SYM_SUFFIX) = \
15
+ PICOBENCH_NAMESPACE::global_registry::new_benchmark (#func, func); \
16
+ } while (0 )
17
+
18
+ #endif // CODSPEED_PICOBENCH_COMPAT_HPP_INCLUDED
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.12)
2
+ include (FetchContent)
3
+
4
+ project (codspeed_picobench_compat VERSION 0.0.0 LANGUAGES CXX)
5
+
6
+ FetchContent_Declare(
7
+ picobench
8
+ GIT_REPOSITORY https://github.com/iboB/picobench.git
9
+ GIT_TAG 7b5de5ab7dad0a9d6627e63c8757c9c4f0c6b1b3 # v2.07
10
+ )
11
+ FetchContent_MakeAvailable(picobench)
12
+
13
+ add_library (codspeed_picobench_compat INTERFACE )
14
+ add_library (codspeed_picobench_compat::codspeed_picobench_compat ALIAS codspeed_picobench_compat)
15
+ target_include_directories (
16
+ codspeed_picobench_compat
17
+ INTERFACE
18
+ ${picobench_SOURCE_DIR} /include
19
+ include
20
+ )
21
+
22
+ add_subdirectory (examples)
23
+
Original file line number Diff line number Diff line change
1
+ macro (pb_example name )
2
+ set (tgt picobench-example-${name} )
3
+ add_executable (${tgt} ${ARGN} )
4
+ target_link_libraries (${tgt} codspeed_picobench_compat)
5
+ set_target_properties (${tgt} PROPERTIES FOLDER example)
6
+ add_custom_target (
7
+ picobench-run-example-${name}
8
+ COMMAND ${tgt}
9
+ )
10
+ endmacro ()
11
+
12
+ pb_example(basic basic.cpp)
Original file line number Diff line number Diff line change
1
+ #define PICOBENCH_DEBUG
2
+ #define PICOBENCH_IMPLEMENT_WITH_MAIN
3
+ #include " codspeed_picobench_compat/picobench.hpp"
4
+
5
+ #include < vector>
6
+ #include < deque>
7
+ #include < cstdlib>
8
+
9
+ void rand_vector (picobench::state& s)
10
+ {
11
+ std::vector<int > v;
12
+ for (auto _ : s)
13
+ {
14
+ v.push_back (rand ());
15
+ }
16
+ }
17
+ PICOBENCH (rand_vector);
18
+
19
+ void rand_vector_reserve (picobench::state& s)
20
+ {
21
+ std::vector<int > v;
22
+ v.reserve (s.iterations ());
23
+ for (auto _ : s)
24
+ {
25
+ v.push_back (rand ());
26
+ }
27
+ }
28
+ PICOBENCH (rand_vector_reserve);
29
+
30
+ void rand_deque (picobench::state& s)
31
+ {
32
+ std::deque<int > v;
33
+ for (auto _ : s)
34
+ {
35
+ v.push_back (rand ());
36
+ }
37
+ }
38
+ PICOBENCH (rand_deque);
Original file line number Diff line number Diff line change
1
+ #ifndef CODSPEED_PICOBENCH_COMPAT_HPP_INCLUDED
2
+ #define CODSPEED_PICOBENCH_COMPAT_HPP_INCLUDED
3
+
4
+ #include " picobench/picobench.hpp"
5
+ #include < iostream>
6
+
7
+ // Undefine the original PICOBENCH macro
8
+ // #undef PICOBENCH
9
+
10
+ // Define a new PICOBENCH macro that wraps the original functionality
11
+ #define PICOBENCH2 (func ) \
12
+ do { \
13
+ std::cout << " Registering benchmark for " << #func << std::endl; \
14
+ static auto & I_PICOBENCH_PP_CAT (picobench, PICOBENCH_UNIQUE_SYM_SUFFIX) = \
15
+ PICOBENCH_NAMESPACE::global_registry::new_benchmark (#func, func); \
16
+ } while (0 )
17
+
18
+ #endif // CODSPEED_PICOBENCH_COMPAT_HPP_INCLUDED
You can’t perform that action at this time.
0 commit comments