Skip to content

Commit 406eb13

Browse files
lemirejaja360
authored andcommitted
minor fixes for the yy PR
1 parent fd753df commit 406eb13

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

benchmarks/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ endif()
6767
target_link_libraries(benchmark PUBLIC fmt)
6868
target_link_libraries(benchmark PUBLIC cxxopts)
6969

70-
#target_link_libraries(benchmark PUBLIC grisu2)
7170
target_link_libraries(benchmark PUBLIC yy_double)
7271
target_link_libraries(benchmark PUBLIC double-conversion)
7372
target_link_libraries(benchmark PUBLIC ryu::ryu)

benchmarks/algorithms.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
#include "ryu/ryu.h"
3333
#include "schubfach_32.h"
3434
#include "schubfach_64.h"
35+
#if (__SIZEOF_INT128__ == 16) && (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER))
3536
#include "yy_double.h"
36-
37+
#define YY_DOUBLE_SUPPORTED 1
38+
#else
39+
#define YY_DOUBLE_SUPPORTED 0
40+
#endif
3741
namespace Benchmarks {
3842

3943
enum Algorithm {
@@ -54,7 +58,7 @@ enum Algorithm {
5458
STD_TO_CHARS = 14,
5559
GRISU3 = 15,
5660
YY_DOUBLE = 16,
57-
COUNT = 17,
61+
COUNT // Keep last
5862
};
5963

6064
template<typename T>
@@ -92,6 +96,7 @@ int errol3(T d, std::span<char>& buffer) {
9296
errol3_dtoa(d, buffer.data()); // returns the exponent
9397
return std::strlen(buffer.data());
9498
#else
99+
std::cerr << "errol3 not supported" << std::endl;
95100
std::abort();
96101
#endif
97102
}
@@ -150,6 +155,7 @@ int netlib(T d, std::span<char>& buffer) {
150155
std::abort();
151156
}
152157
#else
158+
std::cerr << "netlib not supported" << std::endl;
153159
std::abort();
154160
#endif
155161
}
@@ -224,11 +230,15 @@ int double_conversion(T d, std::span<char>& buffer) {
224230
return strlen(builder.Finalize());
225231
}
226232

227-
// No yy_float implementation
228233
template<arithmetic_float T>
229234
int yy_double(T d, std::span<char>& buffer) {
235+
#if YY_DOUBLE_SUPPORTED
230236
const char* end_ptr = yy_double_to_string(d, buffer.data());
231237
return end_ptr - buffer.data();
238+
#else
239+
std::cerr << "yy_double not supported" << std::endl;
240+
std::abort();
241+
#endif
232242
}
233243

234244
template<arithmetic_float T>
@@ -252,6 +262,7 @@ int std_to_chars(T d, std::span<char>& buffer) {
252262
}
253263
return p - buffer.data();
254264
#else
265+
std::cerr << "std::to_chars not supported" << std::endl;
255266
std::abort();
256267
#endif
257268
}

benchmarks/benchmark.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ void process(const std::vector<T> &lines,
7575
std::cout << "# skipping " << algo.name << std::endl;
7676
continue;
7777
}
78-
7978
pretty_print(lines, algo.name, [&algo](const std::vector<T> &lines) -> int {
8079
int volume = 0;
8180
char buf[100];
@@ -198,7 +197,7 @@ int main(int argc, char **argv) {
198197
args[Benchmarks::ABSEIL] = { "abseil" , Benchmarks::abseil<T> , ABSEIL_SUPPORTED };
199198
args[Benchmarks::STD_TO_CHARS] = { "std::to_chars" , Benchmarks::std_to_chars<T> , TO_CHARS_SUPPORTED };
200199
args[Benchmarks::GRISU3] = { "grisu3" , Benchmarks::grisu3<T> , true };
201-
args[Benchmarks::YY_DOUBLE] = { "yy_double" , Benchmarks::yy_double<T> , true };
200+
args[Benchmarks::YY_DOUBLE] = { "yy_double" , Benchmarks::yy_double<T> , YY_DOUBLE_SUPPORTED };
202201
return args;
203202
};
204203

0 commit comments

Comments
 (0)