Skip to content

Commit 96c0dcb

Browse files
committed
adding errol
1 parent dc055e2 commit 96c0dcb

File tree

4 files changed

+47
-20
lines changed

4 files changed

+47
-20
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_C_STANDARD 99)
77
set(CMAKE_C_STANDARD_REQUIRED ON)
88

9-
cmake_policy(SET CMP0169 OLD) # Prevent warning when using FetchContent_Populate
9+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
10+
cmake_policy(SET CMP0169 OLD) # Prevent warning when using FetchContent_Populate
11+
endif()
1012

1113
include(CheckCXXCompilerFlag)
1214
unset(FASTPFOR_COMPILER_SUPPORTS_MARCH_NATIVE CACHE)

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ if(teju_has_float128)
3939
endif()
4040
target_link_libraries(benchmark PUBLIC dragonbox::dragonbox_to_chars)
4141
target_link_libraries(benchmark PUBLIC dragon_schubfach_lib)
42-
42+
target_link_libraries(benchmark PUBLIC errol)
4343
target_include_directories(benchmark PUBLIC ${grisu-exact_SOURCE_DIR})

benchmarks/benchmark.cpp

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "grisu_exact.h"
2121
#include "dragon4.h"
2222
#include "schubfach_64.h"
23+
#include "errol.h"
2324

2425
#define IEEE_8087
2526
#include "benchutil.h"
@@ -67,6 +68,16 @@ void process(std::vector<double> &lines) {
6768
return volume;
6869
});
6970

71+
pretty_print(lines, "errol3", [](const std::vector<double> &lines) {
72+
double volume = 0;
73+
char buffer[100];
74+
for (const auto d : lines) {
75+
errol3_dtoa(d, buffer); // returns the exponent?
76+
volume += std::strlen(buffer);
77+
}
78+
return volume;
79+
});
80+
7081
pretty_print(lines, "std::to_string", [](const std::vector<double> &lines) {
7182
double volume = 0;
7283
for (const auto d : lines) {
@@ -136,24 +147,6 @@ void process(std::vector<double> &lines) {
136147
return volume;
137148
});
138149

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-
157150
pretty_print(lines, "schubfach", [](const std::vector<double> &lines) {
158151
double volume = 0;
159152
char buffer[100];
@@ -224,6 +217,26 @@ void process(std::vector<double> &lines) {
224217
}
225218
return volume;
226219
});
220+
221+
222+
#if FROM_CHARS_DOUBLE_SUPPORTED
223+
pretty_print(lines, "std::to_chars", [](const std::vector<double> &lines) {
224+
double volume = 0;
225+
char buffer[100];
226+
for (const auto d : lines) {
227+
const auto [p, ec] = std::to_chars(buffer, buffer + sizeof(buffer), d);
228+
if(ec != std::errc()) {
229+
std::cerr << "problem with " << d << std::endl;
230+
std::abort();
231+
}
232+
volume += p - buffer;
233+
}
234+
return volume;
235+
});
236+
#else
237+
std::cout << "# std::to_chars not supported" << std::endl;
238+
#endif
239+
227240
}
228241

229242
void fileload(const char *filename) {

dependencies/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,15 @@ CPMAddPackage(
103103
VERSION 3.2.0
104104
OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES"
105105
)
106+
107+
108+
CPMAddPackage(
109+
NAME errol
110+
GITHUB_REPOSITORY marcandrysco/Errol
111+
GIT_TAG 5364de4
112+
DOWNLOAD_ONLY ON
113+
)
114+
115+
116+
add_library(errol STATIC "${errol_SOURCE_DIR}/lib/errol.c")
117+
target_include_directories(errol SYSTEM PUBLIC "${errol_SOURCE_DIR}/lib")

0 commit comments

Comments
 (0)