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
4 changes: 4 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ else(TARGET swift_lib)
endif(TARGET swift_lib)
target_include_directories(benchmark_deps INTERFACE ${grisu-exact_SOURCE_DIR})

add_library(zmij_lib STATIC ${zmij_SOURCE_DIR}/zmij.cc)
target_include_directories(zmij_lib PUBLIC ${zmij_SOURCE_DIR})
target_link_libraries(benchmark_deps INTERFACE zmij_lib)

target_link_libraries(benchmark PUBLIC benchmark_deps)

if(TO_CHARS_OK AND FROM_CHARS_OK)
Expand Down
11 changes: 8 additions & 3 deletions benchmarks/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
#include <gdtoa.h> // Netlib
#endif

#include <fmt/format.h>

#include <array>
#include <span>

#include <fmt/format.h>
#include "zmij.h"
#include "cpp/common/traits.hpp" // Teju Jagua
#include "PrintFloat.h" // Dragon4
#include "double-conversion/double-conversion.h"
Expand Down Expand Up @@ -352,6 +351,11 @@ int ryu(T d, std::span<char>& buffer) {
return d2s_buffered_n(d, buffer.data());
}

template<arithmetic_float T>
int zmij(T d, std::span<char>& buffer) {
return zmij::write(buffer.data(), buffer.size(), d);
}

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 @@ -615,6 +619,7 @@ std::vector<BenchArgs<T>> initArgs(bool use_errol = false, size_t repeat = 0, si
args.emplace_back("double_conversion" , wrap(s::double_conversion<T>) , true);
args.emplace_back("swiftDtoa" , wrap(s::swiftDtoa<T>) , SWIFT_LIB_SUPPORTED);
args.emplace_back("yy_double" , wrap(s::yy_double<T>) , YY_DOUBLE_SUPPORTED && std::is_same_v<T, double>);
args.emplace_back("zmij 1.0" , wrap(s::zmij<T>) , true);
args.emplace_back("std::to_chars" , wrap(s::std_to_chars<T>) , TO_CHARS_SUPPORTED);
// to_string, snprintf and abseil do not support shortest-length representation
// grisu2 does not round-trip correctly
Expand Down
10 changes: 10 additions & 0 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ FetchContent_MakeAvailable(grisu-exact)
set(grisu-exact_SOURCE_DIR ${grisu-exact_SOURCE_DIR} PARENT_SCOPE)
message(STATUS "grisu source directory: ${grisu-exact_SOURCE_DIR}")

FetchContent_Declare(
zmij
GIT_REPOSITORY https://github.com/vitaut/zmij
GIT_TAG tags/v1.0
GIT_SHALLOW TRUE
)
FetchContent_Populate(zmij)
set(zmij_SOURCE_DIR ${zmij_SOURCE_DIR} PARENT_SCOPE)
message(STATUS "zmij source directory: ${zmij_SOURCE_DIR}")

FetchContent_Declare(
dragonbox
GIT_REPOSITORY https://github.com/jk-jeon/dragonbox
Expand Down