Skip to content

benchmark of performance-critical methods provided by the q-tee library against standard and external implementations

License

Notifications You must be signed in to change notification settings

q-tee/benchmark

Repository files navigation

about

benchmark of performance-critical methods provided by q-tee library against standard and external implementations.

results

table of the already measured results can be found in the results directory. note that it doesn't verify the correctness or compliance of the algorithms used. to verify correctness of the q-tee library methods, follow the test project.

here is a chart visualization of the results measured @ 4.21GHz, compiled with MSVC 2022, run on Windows 11 64-bit:

double to string conversion

measurements were made on 1024 values, which were generated randomly in the range [-1.0 .. 1.0] (small), [1.0 .. 1e15] (medium), [1e53 .. 1e308] (large) and run 16 times. the minimum time duration is measured over 10 trials.

implementation note
std::sprintf (MSC) ✅ (reference)
std::to_string (MSC) doesn't support exact number of precision digits, fixed to 6. may perform heap allocations. so small, medium and large measurements are biased
std::to_chars (MSC) rounding doesn't match to reference results (e.g. -0.91942582403655604 being printed as -0.91942582403655688)
std::ostringstream
stbsp_snprintf rounding doesn't match to reference results (e.g. 0.50597744914400899 being printed as 0.50597744914400900)
double_conversion::ToFixed doesn't support fixed output for values greater than 1e60, so large measurements are wrong
dtoa_milo doesn't handle special cases (inf, nan). rounding doesn't match to reference results (e.g. 0.36405244231922773 being printed as 0.36405244231922775). precision digits doesn't always match to reference results (e.g. 0.42825863483271798 being printed as 0.428258634832718)
d2fixed_buffered
fpconv_dtoa precision digits doesn't always match to reference results (e.g. 0.43394907957111351 being printed as 0.4339490795711135)
CRT::RealToString

visualization visualization

string to double conversion

measurements were made on 1024 strings converted from randomly generated values in the range [-1.0 .. 1.0] (small), [1.0 .. 1e15] (medium), [1e53 .. 1e308] (large) and run 16 times. the minimum time duration is measured over 10 trials.

implementation note
std::strtod (MSC) ✅ (reference)
std::from_chars (MSC) ✅ conditionally uses Ryu algorithm internally
s2d doesn't support values with more than 17 digits, so medium and large measurements are wrong
CRT::StringToReal

visualization visualization

build

  • build with Visual Studio:
  1. open the solution in repository root directory
  2. select target architecture and build type
  3. build the solution
  4. output files will be written to the build directory
  • build with CMake:
  1. open terminal in repository root directory
  2. create the project and build
user@machine:~/benchmark$ cmake -B intermediate -D CMAKE_BUILD_TYPE=Release
user@machine:~/benchmark$ cmake --build intermediate --config=Release
  1. output files will be written to the build directory

usage

to add your own algorithm into the benchmark, follow these steps:

  1. add your implementation files into dependencies directory
  2. create header file in the appropriate tests directory (e.g. atod, dtoa, itoa, etc)
  3. create a class declaring your implementation based on one of the available interfaces (e.g. CValueToString, CStringToValue, etc)
  4. override GetName() and GetMethodName() methods with your library name and the name of the used function, respectively
  5. create a static method that matches the prototype and set it via the constructor
  6. add a instance to appropriate bench object in the appropriate test file

further information

you can read about installation of particular libraries, contributing and look for other general information on the q-tee main page.

About

benchmark of performance-critical methods provided by the q-tee library against standard and external implementations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published