Skip to content

Commit 151e9e1

Browse files
committed
fix(google_benchmark): remarks from PR
1 parent 10fe19b commit 151e9e1

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

google_benchmark/include/benchmark/benchmark.h

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,27 @@ class Fixture : public internal::Benchmark {
14421442
#include <filesystem>
14431443
#define CUR_FILE \
14441444
std::filesystem::relative(__FILE__, CODSPEED_GIT_ROOT_DIR).string() + "::"
1445+
1446+
// Transforms `BM_Foo<int, double>` into `BM_Foo[int, double]`.
14451447
#define TYPE_START "["
14461448
#define TYPE_END "]"
1447-
#define FUNC_TEST_SEP "::"
1449+
1450+
// Transforms `BM_Foo/int_arg` into `BM_Foo[int_arg]`.
1451+
#define NAME_START "["
1452+
#define NAME_END "]"
1453+
1454+
// Extra space after the comma for readability
1455+
#define COMMA ", "
14481456
#else
14491457
#define CUR_FILE std::string()
1458+
14501459
#define TYPE_START "<"
14511460
#define TYPE_END ">"
1452-
#define FUNC_TEST_SEP "/"
1461+
1462+
#define NAME_START "/"
1463+
#define NAME_END ""
1464+
1465+
#define COMMA ","
14531466
#endif
14541467

14551468
#define BENCHMARK(...) \
@@ -1481,7 +1494,7 @@ class Fixture : public internal::Benchmark {
14811494
BENCHMARK_PRIVATE_DECLARE(_benchmark_) = \
14821495
(::benchmark::internal::RegisterBenchmarkInternal( \
14831496
std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1484-
CUR_FILE + #func FUNC_TEST_SEP #test_case_name, \
1497+
CUR_FILE + #func NAME_START #test_case_name NAME_END, \
14851498
[](::benchmark::State& st) { func(st, __VA_ARGS__); })))
14861499

14871500
// This will register a benchmark for a templatized function. For example:
@@ -1502,7 +1515,7 @@ class Fixture : public internal::Benchmark {
15021515
BENCHMARK_PRIVATE_DECLARE(n) = \
15031516
(::benchmark::internal::RegisterBenchmarkInternal( \
15041517
std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1505-
CUR_FILE + #n TYPE_START #a "," #b TYPE_END, n<a, b>)))
1518+
CUR_FILE + #n TYPE_START #a COMMA #b TYPE_END, n<a, b>)))
15061519

15071520
#define BENCHMARK_TEMPLATE(n, ...) \
15081521
BENCHMARK_PRIVATE_DECLARE(n) = \
@@ -1531,13 +1544,22 @@ class Fixture : public internal::Benchmark {
15311544
BENCHMARK_CAPTURE(func<a>, test_case_name, __VA_ARGS__)
15321545
#endif
15331546

1547+
#ifdef CODSPEED_ENABLED
1548+
#define BENCHMARK_TEMPLATE2_CAPTURE(func, a, b, test_case_name, ...) \
1549+
BENCHMARK_PRIVATE_DECLARE(func) = \
1550+
(::benchmark::internal::RegisterBenchmarkInternal( \
1551+
std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1552+
CUR_FILE + #func "[" #test_case_name COMMA #a COMMA #b "]", \
1553+
[](::benchmark::State& st) { func<a, b>(st, __VA_ARGS__); })))
1554+
#else
15341555
#define BENCHMARK_TEMPLATE2_CAPTURE(func, a, b, test_case_name, ...) \
15351556
BENCHMARK_PRIVATE_DECLARE(func) = \
15361557
(::benchmark::internal::RegisterBenchmarkInternal( \
15371558
std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1538-
CUR_FILE + #func TYPE_START #a \
1539-
"," #b TYPE_END FUNC_TEST_SEP #test_case_name, \
1559+
#func "<" #a "," #b ">" \
1560+
"/" #test_case_name, \
15401561
[](::benchmark::State& st) { func<a, b>(st, __VA_ARGS__); })))
1562+
#endif
15411563

15421564
#define BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \
15431565
class BaseClass##_##Method##_Benchmark : public BaseClass { \
@@ -1688,7 +1710,6 @@ struct BENCHMARK_EXPORT SystemInfo {
16881710
// which allows individual fields to be modified or cleared before
16891711
// building the final name using 'str()'.
16901712
struct BENCHMARK_EXPORT BenchmarkName {
1691-
std::string path;
16921713
std::string function_name;
16931714
std::string args;
16941715
std::string min_time;

0 commit comments

Comments
 (0)