|
20 | 20 | #include "grisu_exact.h" |
21 | 21 | #include "dragon4.h" |
22 | 22 | #include "schubfach_64.h" |
| 23 | +#if __has_include("errol.h") |
| 24 | +#include "errol.h" |
| 25 | +#define ERROL_SUPPORTED 1 |
| 26 | +#else |
| 27 | +#define ERROL_SUPPORTED 0 |
| 28 | +#endif |
23 | 29 |
|
24 | 30 | #define IEEE_8087 |
25 | 31 | #include "benchutil.h" |
@@ -66,7 +72,20 @@ void process(std::vector<double> &lines) { |
66 | 72 | } |
67 | 73 | return volume; |
68 | 74 | }); |
69 | | - |
| 75 | + |
| 76 | +#if ERROL_SUPPORTED |
| 77 | + pretty_print(lines, "errol3", [](const std::vector<double> &lines) { |
| 78 | + double volume = 0; |
| 79 | + char buffer[100]; |
| 80 | + for (const auto d : lines) { |
| 81 | + errol3_dtoa(d, buffer); // returns the exponent? |
| 82 | + volume += std::strlen(buffer); |
| 83 | + } |
| 84 | + return volume; |
| 85 | + }); |
| 86 | +#else |
| 87 | + std::cout << "# errol not supported" << std::endl; |
| 88 | +#endif // ERROL_SUPPORTED |
70 | 89 | pretty_print(lines, "std::to_string", [](const std::vector<double> &lines) { |
71 | 90 | double volume = 0; |
72 | 91 | for (const auto d : lines) { |
@@ -136,24 +155,6 @@ void process(std::vector<double> &lines) { |
136 | 155 | return volume; |
137 | 156 | }); |
138 | 157 |
|
139 | | -#if FROM_CHARS_DOUBLE_SUPPORTED |
140 | | - pretty_print(lines, "std::to_chars", [](const std::vector<double> &lines) { |
141 | | - double volume = 0; |
142 | | - char buffer[100]; |
143 | | - for (const auto d : lines) { |
144 | | - const auto [p, ec] = std::to_chars(buffer, buffer + sizeof(buffer), d); |
145 | | - if(ec != std::errc()) { |
146 | | - std::cerr << "problem with " << d << std::endl; |
147 | | - std::abort(); |
148 | | - } |
149 | | - volume += p - buffer; |
150 | | - } |
151 | | - return volume; |
152 | | - }); |
153 | | -#else |
154 | | - std::cout << "# std::to_chars not supported" << std::endl; |
155 | | -#endif |
156 | | - |
157 | 158 | pretty_print(lines, "schubfach", [](const std::vector<double> &lines) { |
158 | 159 | double volume = 0; |
159 | 160 | char buffer[100]; |
@@ -224,6 +225,26 @@ void process(std::vector<double> &lines) { |
224 | 225 | } |
225 | 226 | return volume; |
226 | 227 | }); |
| 228 | + |
| 229 | + |
| 230 | +#if FROM_CHARS_DOUBLE_SUPPORTED |
| 231 | + pretty_print(lines, "std::to_chars", [](const std::vector<double> &lines) { |
| 232 | + double volume = 0; |
| 233 | + char buffer[100]; |
| 234 | + for (const auto d : lines) { |
| 235 | + const auto [p, ec] = std::to_chars(buffer, buffer + sizeof(buffer), d); |
| 236 | + if(ec != std::errc()) { |
| 237 | + std::cerr << "problem with " << d << std::endl; |
| 238 | + std::abort(); |
| 239 | + } |
| 240 | + volume += p - buffer; |
| 241 | + } |
| 242 | + return volume; |
| 243 | + }); |
| 244 | +#else |
| 245 | + std::cout << "# std::to_chars not supported" << std::endl; |
| 246 | +#endif |
| 247 | + |
227 | 248 | } |
228 | 249 |
|
229 | 250 | void fileload(const char *filename) { |
|
0 commit comments