Commit Graph

2 Commits

Author SHA1 Message Date
JCrawfy
7ba36b5e73 fix dumb bug in input randomiser, add basic double->string benchmarks
* input randomiser was feeding a constant value previously, now actually randomising
* start to_string with the current method (sstream), an faster more correct version (sstream_cached), snprintf, and std::to_chars
** NOTE: only std::to_chars and sstream_cached are correct in the face of locales

Run on (4 X 3500 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 262K (x4)
  L3 Unified 6291K (x1)
-------------------------------------------------------------------------------------------------------------
Benchmark                                                                   Time             CPU   Iterations
-------------------------------------------------------------------------------------------------------------
RandFloatStrs/double_from_string_sstream                                 1012 ns         1001 ns       640000
RandFloatStrs/double_from_string_strtod                                   276 ns          276 ns      2488889
RandFloatStrs/double_from_string_strtod_fixed                             312 ns          308 ns      2133333
RandFloatStrs/double_from_string_strtod_fixed_const_ref                   307 ns          300 ns      2240000
RandFloatStrs/double_from_string_std_from_chars                           194 ns          188 ns      3733333
RandFloatCommaStrs/double_from_string_strtod_fixed_comma_ref              315 ns          314 ns      2240000
RandFloatCommaStrs/double_from_string_strtod_fixed_comma_const_ref        306 ns          305 ns      2357895
RandFloats/string_from_double_sstream                                    1372 ns         1381 ns       497778
RandFloats/string_from_double_sstream_cached                             1136 ns         1123 ns       640000
RandFloats/string_from_double_snprintf                                    536 ns          516 ns      1000000
RandFloats/string_from_double_std_to_chars                                116 ns          115 ns      6400000
2020-02-29 22:59:25 +13:00
JCrawfy
0adb8a69b1 add micro benchmarking project, setup number parsing benchmark
relating to previous work https://github.com/tfussell/xlnt/issues/422
Results are matching what was observed at the time ^^ was being worked on
std::from_chars is included as the target to beat, but since only MSVC has it for floating point it's not
hugely useful yet

uniform real distribution is probably a horrible choice, and it might be good to randomise the number
of sf in each string also (currently the y all end up at max length)

Run on (4 X 3500 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 262K (x4)
  L3 Unified 6291K (x1)
----------------------------------------------------------------------------------------------------------
Benchmark                                                                Time             CPU   Iterations
----------------------------------------------------------------------------------------------------------
RandFloats/double_from_string_sstream                                  804 ns          820 ns       896000
RandFloats/double_from_string_strtod                                   163 ns          162 ns      5973333
RandFloats/double_from_string_strtod_fixed                             175 ns          172 ns      5352107
RandFloats/double_from_string_strtod_fixed_const_ref                   150 ns          152 ns      5352107
RandFloats/double_from_string_std_from_chars                          87.1 ns         88.3 ns      9557333
RandFloatsComma/double_from_string_strtod_fixed_comma_ref              172 ns          173 ns      5146257
RandFloatsComma/double_from_string_strtod_fixed_comma_const_ref        180 ns          175 ns      5352107
2020-02-29 22:11:31 +13:00