@@ -74,17 +74,10 @@ struct AtomicBenchmarkSums {
74
74
};
75
75
76
76
AtomicBenchmarkSums all_results;
77
- const char *header_format_string =
78
- " Benchmark | Cycles | Min | Max | Iterations | "
79
- " Time | Stddev | Threads |\n " ;
80
- const char *output_format_string =
81
- " %-20s |%8ld |%8ld |%8ld |%11ld |%9ld %2s |%9ld |%9d |\n " ;
82
-
83
77
constexpr auto GREEN = " \033 [32m" ;
84
78
constexpr auto RESET = " \033 [0m" ;
85
79
86
80
void print_results (Benchmark *b) {
87
-
88
81
BenchmarkResult result;
89
82
cpp::atomic_thread_fence (cpp::MemoryOrder::RELEASE);
90
83
int num_threads = all_results.active_threads .load (cpp::MemoryOrder::RELAXED);
@@ -104,35 +97,37 @@ void print_results(Benchmark *b) {
104
97
const uint64_t duration_us = duration_ns / 1000 ;
105
98
const uint64_t duration_ms = duration_ns / (1000 * 1000 );
106
99
uint64_t converted_duration = duration_ns;
107
- cpp::string time_unit;
100
+ const char * time_unit;
108
101
if (duration_ms != 0 ) {
109
102
converted_duration = duration_ms;
110
- time_unit = cpp::string ( " ms" ) ;
103
+ time_unit = " ms" ;
111
104
} else if (duration_us != 0 ) {
112
105
converted_duration = duration_us;
113
- time_unit = cpp::string ( " us" ) ;
106
+ time_unit = " us" ;
114
107
} else {
115
108
converted_duration = duration_ns;
116
- time_unit = cpp::string ( " ns" ) ;
109
+ time_unit = " ns" ;
117
110
}
118
111
result.total_time = converted_duration;
119
112
// result.total_time =
120
113
// all_results.time_sum.load(cpp::MemoryOrder::RELAXED) / num_threads;
121
114
cpp::atomic_thread_fence (cpp::MemoryOrder::RELEASE);
122
115
123
116
LIBC_NAMESPACE::printf (
124
- output_format_string, b-> get_test_name (). data (), result. cycles ,
125
- result. min , result.max , result.total_iterations , result.total_time ,
126
- time_unit. data (), static_cast < uint64_t >( result.standard_deviation ) ,
127
- num_threads);
117
+ " %-20s |%8ld |%8ld |%8ld |%11d |%9ld %2s |%9ld |%9d | \n " ,
118
+ b-> get_test_name (). data () , result.cycles , result.min , result.max ,
119
+ result. total_iterations , result.total_time , time_unit ,
120
+ static_cast < uint64_t >(result. standard_deviation ), num_threads);
128
121
}
129
122
130
123
void print_header () {
131
124
LIBC_NAMESPACE::printf (" %s" , GREEN);
132
125
LIBC_NAMESPACE::printf (" Running Suite: %-10s\n " ,
133
126
benchmarks[0 ]->get_suite_name ().data ());
134
127
LIBC_NAMESPACE::printf (" %s" , RESET);
135
- LIBC_NAMESPACE::printf (header_format_string);
128
+ LIBC_NAMESPACE::printf (" Benchmark | Cycles | Min | Max | "
129
+ " Iterations | "
130
+ " Time | Stddev | Threads |\n " );
136
131
LIBC_NAMESPACE::printf (
137
132
" ---------------------------------------------------------------------"
138
133
" --------------------------------\n " );
0 commit comments