Skip to content

Conversation

AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented Aug 28, 2025

Port benchmark from #1243 (comment) comment.

Changes:

  • Don't hard-code the number of repetitions, this is now determined by the framework
  • Use DoNotOptimize instead of a dummy variable
  • Measure only one conversion rather than whole vector. Primarily because Google Benchmark still shows these bigger times in ns, so they are inconveniently big when measuring them for the whole vector
  • Underscore in benchmark names, as they are now function names
  • N -> n, RT -> Rt, avoiding macro-like names
  • Randomly generated vectors do not persist between tests. I find this easier to maintain this way, despite some runtime cost, feel free to disagree
  • Avoided .size() in a loop. Perf habit: calling vector<T>::size() in a loop may inhibit certain optimizations this doesn't work, we skip adding sometimes, we have to look how many we have generated

Example output:

2025-08-28T09:43:39+03:00
Running out\bench\benchmark-charconv_floats.exe
Run on (12 X 2496 MHz CPU s)
CPU Caches:
  L1 Data 48 KiB (x6)
  L1 Instruction 32 KiB (x6)
  L2 Unified 1280 KiB (x6)
  L3 Unified 12288 KiB (x1)
-------------------------------------------------------------------------
Benchmark                               Time             CPU   Iterations
-------------------------------------------------------------------------
STL_float_plain_shortest             36.2 ns         36.1 ns     19478261
STL_double_plain_shortest            43.8 ns         44.5 ns     17920000
STL_float_scientific_shortest        34.8 ns         34.9 ns     22400000
STL_double_scientific_shortest       43.0 ns         39.1 ns     16000000
STL_float_fixed_shortest             43.0 ns         41.4 ns     16592593
STL_double_fixed_shortest             110 ns          110 ns      6400000
STL_float_general_shortest           35.4 ns         33.5 ns     22400000
STL_double_general_shortest          43.3 ns         43.3 ns     16592593
STL_float_hex_shortest               18.6 ns         18.4 ns     37333333
STL_double_hex_shortest              22.4 ns         22.0 ns     32000000
STL_float_scientific_8               59.7 ns         55.8 ns     11200000
STL_double_scientific_16             68.4 ns         68.4 ns     11200000
STL_float_fixed_6_lossy              40.6 ns         40.1 ns     17920000
STL_double_fixed_6_lossy             92.8 ns         94.2 ns      8960000
STL_float_general_9                  71.6 ns         69.8 ns      8960000
STL_double_general_17                81.5 ns         77.4 ns      7466667
STL_float_hex_6                      18.2 ns         18.0 ns     37333333
STL_double_hex_13                    21.2 ns         20.4 ns     34461538

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner August 28, 2025 06:46
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Aug 28, 2025
@StephanTLavavej StephanTLavavej added performance Must go faster test Related to test code labels Aug 28, 2025
@StephanTLavavej StephanTLavavej self-assigned this Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster test Related to test code
Projects
Status: Initial Review
Development

Successfully merging this pull request may close these issues.

2 participants