Skip to content

Commit 0d7b41c

Browse files
committed
add teju-jagua algorithm in the benchmarks
1 parent c9fa9b2 commit 0d7b41c

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Currently, the following approaches are compared:
1616
- [Ryu](https://github.com/ulfjack/ryu)
1717
- [double-conversion](https://github.com/google/double-conversion)
1818
- [Abseil](https://github.com/abseil/abseil-cpp)
19+
- [Teju Jagua](https://github.com/cassioneri/teju_jagua)
1920

2021
If you have a recent version of CMake (3.15 or better) under linux, you can simply
2122
go in the directory and type the following commands:

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ target_link_libraries(benchmark PUBLIC cxxopts)
3333
target_link_libraries(benchmark PUBLIC grisu2)
3434
target_link_libraries(benchmark PUBLIC double-conversion)
3535
target_link_libraries(benchmark PUBLIC ryu::ryu)
36+
target_link_libraries(benchmark PUBLIC teju)
3637
target_link_libraries(benchmark PUBLIC dragonbox::dragonbox_to_chars)

benchmarks/benchmark.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* data generated.
88
*/
99

10+
// Teju Jagua
11+
#include "cpp/common/traits.hpp"
12+
1013
#ifndef __CYGWIN__
1114
#include "absl/strings/str_cat.h"
1215
#endif
@@ -25,6 +28,7 @@
2528

2629
#include "grisu2.h"
2730
#include "random_generators.h"
31+
#include "decimalToString.h"
2832

2933
#include <charconv>
3034
#include <climits>
@@ -136,6 +140,17 @@ void process(std::vector<double> &lines) {
136140
return volume;
137141
});
138142

143+
pretty_print(lines, "teju_jagua", [](const std::vector<double> &lines) {
144+
double volume = 0;
145+
char buffer[100];
146+
for (const auto d : lines) {
147+
const auto fields = teju::traits_t<double>::teju(d);
148+
const bool sign = (*reinterpret_cast<const uint64_t*>(&d) >> 63) & 1;
149+
volume += to_chars(fields.mantissa, fields.exponent, sign, buffer);
150+
}
151+
return volume;
152+
});
153+
139154
pretty_print(lines, "double_conversion", [](const std::vector<double> &lines) {
140155
double volume = 0;
141156
const double_conversion::DoubleToStringConverter converter(

dependencies/CMakeLists.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,28 @@ endif()
2626

2727
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Disable deprecation warnings" FORCE)
2828
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
29-
#cmake_policy(SET CMP0077 NEW)
30-
FetchContent_Declare(doubleconversion
31-
GIT_REPOSITORY https://github.com/google/double-conversion.git
32-
GIT_TAG "v3.1.5")
33-
FetchContent_GetProperties(doubleconversion)
29+
30+
FetchContent_Declare(
31+
doubleconversion
32+
GIT_REPOSITORY https://github.com/google/double-conversion.git
33+
GIT_TAG "v3.1.5")
3434
FetchContent_MakeAvailable(doubleconversion)
3535

36+
FetchContent_Declare(
37+
teju_jagua
38+
GIT_REPOSITORY https://github.com/jaja360/teju_jagua.git
39+
GIT_TAG main
40+
GIT_SHALLOW TRUE
41+
)
42+
FetchContent_MakeAvailable(teju_jagua)
43+
3644
#CPMAddPackage("gh:ulfjack/[email protected]")
3745
FetchContent_Declare(
3846
ryu
3947
GIT_REPOSITORY https://github.com/ulfjack/ryu
4048
GIT_TAG master
4149
GIT_SHALLOW TRUE
4250
)
43-
4451
FetchContent_MakeAvailable(ryu)
4552

4653
FetchContent_Declare(
@@ -49,7 +56,6 @@ FetchContent_Declare(
4956
GIT_TAG tags/1.1.3
5057
GIT_SHALLOW TRUE
5158
)
52-
5359
FetchContent_MakeAvailable(dragonbox)
5460

5561
CPMAddPackage("gh:fmtlib/fmt#11.0.2")

0 commit comments

Comments
 (0)