Skip to content

Commit b79c3e5

Browse files
committed
Benchmark are updated.
1 parent c54bafd commit b79c3e5

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

benchmarks/benchmark.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
// #define FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
33
// #define FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED
4+
// #define FASTFLOAT_ISNOT_CHECKED_BOUNDS
45

56
#if defined(__linux__) || (__APPLE__ && __aarch64__)
67
#define USING_COUNTERS
@@ -50,14 +51,16 @@ time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
5051
size_t repeat) {
5152
std::vector<event_count> aggregate;
5253
bool printed_bug = false;
53-
for (size_t i = 0; i < repeat; i++) {
54+
for (size_t i = 0; i != repeat; ++i) {
55+
5456
collector.start();
5557
auto const ts = function(lines);
58+
aggregate.push_back(collector.end());
59+
5660
if (ts == 0 && !printed_bug) {
5761
printf("bug\n");
5862
printed_bug = true;
5963
}
60-
aggregate.push_back(collector.end());
6164
}
6265
return aggregate;
6366
}
@@ -130,18 +133,21 @@ time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
130133
double average = 0;
131134
double min_value = DBL_MAX;
132135
bool printed_bug = false;
133-
for (size_t i = 0; i < repeat; i++) {
136+
for (size_t i = 0; i != repeat; ++i) {
137+
134138
t1 = std::chrono::high_resolution_clock::now();
135139
auto const ts = function(lines);
136-
if (ts == 0 && !printed_bug) {
137-
printf("bug\n");
138-
printed_bug = true;
139-
}
140140
t2 = std::chrono::high_resolution_clock::now();
141+
141142
double const dif = static_cast<double>(
142143
std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count());
143144
average += dif;
144145
min_value = min_value < dif ? min_value : dif;
146+
147+
if (ts == 0 && !printed_bug) {
148+
printf("bug\n");
149+
printed_bug = true;
150+
}
145151
}
146152
average /= repeat;
147153
return std::make_pair(min_value, average);
@@ -162,7 +168,7 @@ void pretty_print(size_t volume, size_t number_of_floats,
162168
inline std::u16string widen(std::string const &line) {
163169
std::u16string u16line;
164170
u16line.resize(line.size());
165-
for (size_t i = 0; i < line.size(); ++i) {
171+
for (size_t i = 0; i != line.size(); ++i) {
166172
u16line[i] = char16_t(line[i]);
167173
}
168174
return u16line;
@@ -178,7 +184,7 @@ std::vector<std::u16string> widen(const std::vector<std::string> &lines) {
178184
}
179185

180186
void process(std::vector<std::string> &lines, size_t volume) {
181-
size_t const repeat = 1000;
187+
size_t constexpr repeat = 1000;
182188
double volumeMB = volume / (1024. * 1024.);
183189
std::cout << "ASCII volume = " << volumeMB << " MB " << std::endl;
184190
pretty_print(volume, lines.size(), "fastfloat (64)",
@@ -232,6 +238,9 @@ int main(int argc, char **argv) {
232238
std::cout << "# FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED is enabled"
233239
<< std::endl;
234240
#endif
241+
#ifdef FASTFLOAT_ISNOT_CHECKED_BOUNDS
242+
std::cout << "# FASTFLOAT_ISNOT_CHECKED_BOUNDS is enabled" << std::endl;
243+
#endif
235244
#ifdef USING_COUNTERS
236245
if (collector.has_events()) {
237246
std::cout << "# Using hardware counters" << std::endl;

0 commit comments

Comments
 (0)