Skip to content

Commit

Permalink
Added PICOBENCH_UNIQUE_SYM_SUFFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
iboB committed Mar 20, 2023
1 parent 0133704 commit 95ff13b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions include/picobench/picobench.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// picobench v2.02
// picobench v2.03
// https://github.com/iboB/picobench
//
// A micro microbenchmarking library in a single header file
Expand Down Expand Up @@ -30,6 +30,7 @@
//
// VERSION HISTORY
//
// 2.03 (2023-03-20) * Added PICOBENCH_UNIQUE_SYM_SUFFIX
// 2.02 (2023-02-16) * Fixed same-func warning if user data is different
// * Macro PICOBENCH_NAMESPACE to change namespace
// * Changed marking of baseline in human-readable reports
Expand Down Expand Up @@ -326,15 +327,22 @@ class global_registry

}

// Optionally define PICOBENCH_UNIQUE_SYM_SUFFIX to replace __LINE__ with something
// non standard like __COUNTER__ in case you need multiple PICOBENCH macros in a
// macro of yours
#if !defined(PICOBENCH_UNIQUE_SYM_SUFFIX)
#define PICOBENCH_UNIQUE_SYM_SUFFIX __LINE__
#endif

#define I_PICOBENCH_PP_CAT(a, b) I_PICOBENCH_PP_INTERNAL_CAT(a, b)
#define I_PICOBENCH_PP_INTERNAL_CAT(a, b) a##b

#define PICOBENCH_SUITE(name) \
static int I_PICOBENCH_PP_CAT(picobench_suite, __LINE__) = \
static int I_PICOBENCH_PP_CAT(picobench_suite, PICOBENCH_UNIQUE_SYM_SUFFIX) = \
PICOBENCH_NAMESPACE::global_registry::set_bench_suite(name)

#define PICOBENCH(func) \
static auto& I_PICOBENCH_PP_CAT(picobench, __LINE__) = \
static auto& I_PICOBENCH_PP_CAT(picobench, PICOBENCH_UNIQUE_SYM_SUFFIX) = \
PICOBENCH_NAMESPACE::global_registry::new_benchmark(#func, func)

#if defined(PICOBENCH_IMPLEMENT_WITH_MAIN)
Expand Down

0 comments on commit 95ff13b

Please sign in to comment.