Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Currently, the following approaches are compared:
- [schubfach](https://github.com/abolz/Drachennest/blob/master/src/schubfach_64.cc)
- [Dragonbox](https://github.com/jk-jeon/dragonbox)
- [Ryu](https://github.com/ulfjack/ryu)
- [xjb](https://github.com/xjb714/xjb)
- [double-conversion](https://github.com/google/double-conversion)
- [Abseil](https://github.com/abseil/abseil-cpp)
- [Teju Jagua](https://github.com/cassioneri/teju_jagua)
Expand Down
8 changes: 7 additions & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ else()
target_compile_definitions(benchmark_deps INTERFACE ERROL_SUPPORTED=0)
endif()

if(TARGET xjb AND NOT MSVC)
target_link_libraries(benchmark_deps INTERFACE xjb)
target_compile_definitions(benchmark_deps INTERFACE XJB_SUPPORTED=1)
else()
target_compile_definitions(benchmark_deps INTERFACE XJB_SUPPORTED=0)
endif()

target_link_libraries(benchmark_deps INTERFACE fmt)
target_link_libraries(benchmark_deps INTERFACE cxxopts)

Expand Down Expand Up @@ -108,4 +115,3 @@ if(TO_CHARS_OK AND FROM_CHARS_OK)

target_link_libraries(thoroughfloat64 PUBLIC benchmark_deps)
endif(TO_CHARS_OK AND FROM_CHARS_OK)

15 changes: 15 additions & 0 deletions benchmarks/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#if SWIFT_LIB_SUPPORTED
#include "swift/Runtime/SwiftDtoa.h"
#endif
#if XJB_SUPPORTED
#include "ftoa.h"
#endif
#if (__SIZEOF_INT128__ == 16) && (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER))
#include "yy_double.h"
#define YY_DOUBLE_SUPPORTED 1
Expand Down Expand Up @@ -361,6 +364,17 @@ int zmij(T d, std::span<char>& buffer) {
return zmij::write(buffer.data(), buffer.size(), d);
}

template<arithmetic_float T>
int xjb(T d, std::span<char>& buffer) {
#if XJB_SUPPORTED
const char* end_ptr = xjb_ftoa(d, buffer.data());
return end_ptr - buffer.data();
#else
std::cerr << "xjb not supported" << std::endl;
std::abort();
#endif
}

template<arithmetic_float T>
int teju_jagua(T d, std::span<char>& buffer) {
const auto fields = teju::traits_t<T>::teju(d);
Expand Down Expand Up @@ -622,6 +636,7 @@ std::vector<BenchArgs<T>> initArgs(bool use_errol = false, size_t repeat = 0, si
args.emplace_back("dragonboxlm" , wrap(s::dragonboxlm<T>) , true);
args.emplace_back("dragonbox 1.1.3" , wrap(s::dragonbox<T>) , true);
args.emplace_back("ryu" , wrap(s::ryu<T>) , true);
args.emplace_back("xjb 1.4.0" , wrap(s::xjb<T>) , XJB_SUPPORTED);
args.emplace_back("teju_jagua" , wrap(s::teju_jagua<T>) , true);
args.emplace_back("double_conversion" , wrap(s::double_conversion<T>) , true);
args.emplace_back("swiftDtoa" , wrap(s::swiftDtoa<T>) , SWIFT_LIB_SUPPORTED);
Expand Down
9 changes: 9 additions & 0 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ FetchContent_MakeAvailable(ryu)
set(ryu_SOURCE_DIR ${ryu_SOURCE_DIR} PARENT_SCOPE)
message(STATUS "ryu source directory: ${ryu_SOURCE_DIR}")

FetchContent_Declare(
xjb
GIT_REPOSITORY https://github.com/xjb714/xjb.git
GIT_TAG tags/v1.4.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(xjb)
target_include_directories(xjb PUBLIC ${xjb_SOURCE_DIR}/src)

FetchContent_Declare(
grisu-exact
GIT_REPOSITORY https://github.com/jk-jeon/Grisu-Exact
Expand Down
Loading