@@ -1439,9 +1439,16 @@ class Fixture : public internal::Benchmark {
14391439 n) [[maybe_unused]]
14401440
14411441#ifdef CODSPEED_ENABLED
1442+ #include < codspeed.h>
1443+
14421444#include < filesystem>
1445+
14431446#define CUR_FILE \
14441447 std::filesystem::relative (__FILE__, CODSPEED_GIT_ROOT_DIR).string() + "::"
1448+ #define NAMESPACE \
1449+ (([]() { return extract_lambda_namespace (__PRETTY_FUNCTION__); })())
1450+
1451+ #define FILE_AND_NAMESPACE CUR_FILE + NAMESPACE
14451452
14461453// Transforms `BM_Foo<int, double>` into `BM_Foo[int, double]`.
14471454#define TYPE_START " ["
@@ -1454,7 +1461,7 @@ class Fixture : public internal::Benchmark {
14541461// Extra space after the comma for readability
14551462#define COMMA " , "
14561463#else
1457- #define CUR_FILE std::string ()
1464+ #define FILE_AND_NAMESPACE std::string ()
14581465
14591466#define TYPE_START " <"
14601467#define TYPE_END " >"
@@ -1469,7 +1476,7 @@ class Fixture : public internal::Benchmark {
14691476 BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
14701477 (::benchmark::internal::RegisterBenchmarkInternal( \
14711478 std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1472- CUR_FILE + #__VA_ARGS__, __VA_ARGS__)))
1479+ FILE_AND_NAMESPACE + #__VA_ARGS__, __VA_ARGS__)))
14731480
14741481// Old-style macros
14751482#define BENCHMARK_WITH_ARG (n, a ) BENCHMARK(n)->Arg ((a))
@@ -1490,11 +1497,11 @@ class Fixture : public internal::Benchmark {
14901497// }
14911498// /* Registers a benchmark named "BM_takes_args/int_string_test` */
14921499// BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc"));
1493- #define BENCHMARK_CAPTURE (func, test_case_name, ...) \
1494- BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
1495- (::benchmark::internal::RegisterBenchmarkInternal( \
1496- std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1497- CUR_FILE + #func NAME_START #test_case_name NAME_END, \
1500+ #define BENCHMARK_CAPTURE (func, test_case_name, ...) \
1501+ BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
1502+ (::benchmark::internal::RegisterBenchmarkInternal( \
1503+ std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1504+ FILE_AND_NAMESPACE + #func NAME_START #test_case_name NAME_END, \
14981505 [](::benchmark::State& st) { func (st, __VA_ARGS__); })))
14991506
15001507// This will register a benchmark for a templatized function. For example:
@@ -1509,19 +1516,20 @@ class Fixture : public internal::Benchmark {
15091516 BENCHMARK_PRIVATE_DECLARE (n) = \
15101517 (::benchmark::internal::RegisterBenchmarkInternal( \
15111518 std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1512- CUR_FILE + #n TYPE_START #a TYPE_END, n<a>)))
1513-
1514- #define BENCHMARK_TEMPLATE2 (n, a, b ) \
1515- BENCHMARK_PRIVATE_DECLARE (n) = \
1516- (::benchmark::internal::RegisterBenchmarkInternal( \
1517- std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1518- CUR_FILE + #n TYPE_START #a COMMA #b TYPE_END, n<a, b>)))
1519-
1520- #define BENCHMARK_TEMPLATE (n, ...) \
1521- BENCHMARK_PRIVATE_DECLARE (n) = \
1522- (::benchmark::internal::RegisterBenchmarkInternal( \
1523- std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1524- CUR_FILE + #n TYPE_START #__VA_ARGS__ TYPE_END, \
1519+ FILE_AND_NAMESPACE + #n TYPE_START #a TYPE_END, n<a>)))
1520+
1521+ #define BENCHMARK_TEMPLATE2 (n, a, b ) \
1522+ BENCHMARK_PRIVATE_DECLARE (n) = \
1523+ (::benchmark::internal::RegisterBenchmarkInternal( \
1524+ std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1525+ FILE_AND_NAMESPACE + #n TYPE_START #a COMMA #b TYPE_END, \
1526+ n<a, b>)))
1527+
1528+ #define BENCHMARK_TEMPLATE (n, ...) \
1529+ BENCHMARK_PRIVATE_DECLARE (n) = \
1530+ (::benchmark::internal::RegisterBenchmarkInternal( \
1531+ std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1532+ FILE_AND_NAMESPACE + #n TYPE_START #__VA_ARGS__ TYPE_END, \
15251533 n<__VA_ARGS__>)))
15261534
15271535// This will register a benchmark for a templatized function,
@@ -1544,7 +1552,8 @@ class Fixture : public internal::Benchmark {
15441552 BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
15451553 (::benchmark::internal::RegisterBenchmarkInternal( \
15461554 std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1547- CUR_FILE + #func_name NAME_START #test_case_name NAME_END, \
1555+ FILE_AND_NAMESPACE + \
1556+ #func_name NAME_START #test_case_name NAME_END, \
15481557 [](::benchmark::State& st) { func (st, __VA_ARGS__); })))
15491558
15501559#define BENCHMARK_TEMPLATE1_CAPTURE (func, a, test_case_name, ...) \
@@ -1555,11 +1564,12 @@ class Fixture : public internal::Benchmark {
15551564#endif
15561565
15571566#ifdef CODSPEED_ENABLED
1558- #define BENCHMARK_TEMPLATE2_CAPTURE (func, a, b, test_case_name, ...) \
1559- BENCHMARK_PRIVATE_DECLARE (func) = \
1560- (::benchmark::internal::RegisterBenchmarkInternal( \
1561- std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1562- CUR_FILE + #func " [" #test_case_name COMMA #a COMMA #b " ]" , \
1567+ #define BENCHMARK_TEMPLATE2_CAPTURE (func, a, b, test_case_name, ...) \
1568+ BENCHMARK_PRIVATE_DECLARE (func) = \
1569+ (::benchmark::internal::RegisterBenchmarkInternal( \
1570+ std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1571+ FILE_AND_NAMESPACE + #func " [" #test_case_name COMMA #a COMMA #b \
1572+ " ]" , \
15631573 [](::benchmark::State& st) { func<a, b>(st, __VA_ARGS__); })))
15641574#else
15651575#define BENCHMARK_TEMPLATE2_CAPTURE (func, a, b, test_case_name, ...) \
0 commit comments