@@ -56,7 +56,68 @@ static void BM_memcpy(benchmark::State &state) {
5656 delete[] src;
5757 delete[] dst;
5858}
59-
6059BENCHMARK (BM_memcpy)->Range(8 , 8 << 10 );
6160
61+ static void BM_some_super_long_name_that_we_dont_want_to_use (
62+ benchmark::State &state) {
63+ for (auto _ : state) {
64+ benchmark::DoNotOptimize (42 );
65+ benchmark::ClobberMemory ();
66+ }
67+ }
68+ BENCHMARK (BM_some_super_long_name_that_we_dont_want_to_use)
69+ ->Name(" BM_short_name" );
70+
71+ template <class ... Args>
72+ void BM_Capture_custom_name (benchmark::State &state, Args &&...args) {
73+ auto args_tuple = std::make_tuple (std::move (args)...);
74+ for (auto _ : state) {
75+ benchmark::DoNotOptimize (args_tuple);
76+ benchmark::ClobberMemory ();
77+ }
78+ }
79+ BENCHMARK_CAPTURE (BM_Capture_custom_name, int_string_test, 42 ,
80+ std::string (" abc::def" ))
81+ ->Name(" BM_Capture_int_string" );
82+ BENCHMARK_CAPTURE (BM_Capture_custom_name, int_test, 42 , 43 )
83+ ->Name(" BM_Capture_int" );
84+
85+ namespace one {
86+ namespace two {
87+ namespace three {
88+ static void BM_nested_namespaces_with_custom_name (benchmark::State &state) {
89+ for (auto _ : state) {
90+ benchmark::DoNotOptimize (42 );
91+ benchmark::ClobberMemory ();
92+ }
93+ }
94+ BENCHMARK (BM_nested_namespaces_with_custom_name)
95+ ->Name (" BM_custom_name_in_namespace" );
96+ } // namespace three
97+ } // namespace two
98+ } // namespace one
99+
100+ // Test with actual numeric parameters
101+ static void BM_with_args (benchmark::State &state) {
102+ for (auto _ : state) {
103+ benchmark::DoNotOptimize (state.range (0 ));
104+ benchmark::ClobberMemory ();
105+ }
106+ }
107+ BENCHMARK (BM_with_args)->Arg(100 )->Arg(1000 );
108+ BENCHMARK (BM_with_args)->Name(" BM_custom_args" )->Arg(100 )->Arg(1000 );
109+
110+ // Test with multiple arguments
111+ static void BM_with_multiple_args (benchmark::State &state) {
112+ for (auto _ : state) {
113+ benchmark::DoNotOptimize (state.range (0 ) + state.range (1 ));
114+ benchmark::ClobberMemory ();
115+ }
116+ }
117+ BENCHMARK (BM_with_multiple_args)->Args({10 , 20 })->Args({100 , 200 });
118+ BENCHMARK (BM_with_multiple_args)
119+ ->Name(" BM_custom_multi" )
120+ ->Args({10 , 20 })
121+ ->Args({100 , 200 });
122+
62123BENCHMARK_MAIN ();
0 commit comments