Skip to content

New benchmark for int64, double and number for both ondemand and dom - #2807

Open
fior512 wants to merge 1 commit into
simdjson:masterfrom
fior512:bench_int_double_num
Open

New benchmark for int64, double and number for both ondemand and dom#2807
fior512 wants to merge 1 commit into
simdjson:masterfrom
fior512:bench_int_double_num

Conversation

@fior512

@fior512 fior512 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Adds benchmarks for:

  • ondemand: get_int64(), get_double() and get_number()
  • dom: get_int64() and get_double()

it uses counters/event_counter.h, create padded_json filled with int64 and/or double (both simultaneously for get_number()).

bench parameters:

  • min_repeat: 10
  • min_time_ns: 40million
  • max_repeat: 10million
  • trials: 3
  • test 3 variables size (scaling test over 5, 12, 19 digits)

Since it benchs 5 functions over 3 sizes, i added compiler flags (as benchmark/dom/parse.cpp does), to test only int64 or double or number; if no flag given, it will run all benchs. Flags are:

  • BENCH_ONLY_INT (through: bench_number_accessors_int)
  • BENCH_ONLY_DOUBLE (through: bench_number_accessors_double)
  • BENCH_ONLY_NUMBER (through: bench_number_accessors_number)

For the same reason, i opted for a sligthly different ouput format that usual (looking for feedbacks).
int32:

Trial 1:
  5 digits:
    ondemand_get_int64           :     3.85 ns/value     1.69 GB/s     5.17 GHz    19.90 cycles/value    85.77 ins./value     4.31 i/c
    dom_get_int64                :     0.22 ns/value    29.91 GB/s     5.06 GHz     1.10 cycles/value     8.00 ins./value     7.27 i/c
  12 digits:
    ondemand_get_int64           :     7.55 ns/value     1.79 GB/s     5.16 GHz    38.95 cycles/value   148.87 ins./value     3.82 i/c
    dom_get_int64                :     0.21 ns/value    64.02 GB/s     5.12 GHz     1.08 cycles/value     8.00 ins./value     7.41 i/c
  19 digits:
    ondemand_get_int64           :    10.47 ns/value     1.96 GB/s     5.26 GHz    55.06 cycles/value   212.58 ins./value     3.86 i/c
    dom_get_int64                :     0.21 ns/value    95.98 GB/s     5.16 GHz     1.10 cycles/value     8.00 ins./value     7.26 i/c

Trial 2:
  5 digits:
    ondemand_get_int64           :     3.83 ns/value     1.70 GB/s     5.22 GHz    19.99 cycles/value    85.77 ins./value     4.29 i/c
    dom_get_int64                :     0.21 ns/value    30.98 GB/s     5.16 GHz     1.08 cycles/value     8.00 ins./value     7.39 i/c
  12 digits:
    ondemand_get_int64           :     7.43 ns/value     1.82 GB/s     5.26 GHz    39.07 cycles/value   148.87 ins./value     3.81 i/c
    dom_get_int64                :     0.20 ns/value    66.41 GB/s     5.15 GHz     1.05 cycles/value     8.00 ins./value     7.64 i/c
  19 digits:
    ondemand_get_int64           :    10.49 ns/value     1.95 GB/s     5.25 GHz    55.07 cycles/value   212.58 ins./value     3.86 i/c
    dom_get_int64                :     0.21 ns/value    99.65 GB/s     5.12 GHz     1.05 cycles/value     8.00 ins./value     7.60 i/c

Trial 3:
  5 digits:
    ondemand_get_int64           :     3.85 ns/value     1.69 GB/s     5.17 GHz    19.93 cycles/value    85.77 ins./value     4.30 i/c
    dom_get_int64                :     0.21 ns/value    30.63 GB/s     5.16 GHz     1.10 cycles/value     8.00 ins./value     7.30 i/c
  12 digits:
    ondemand_get_int64           :     7.43 ns/value     1.82 GB/s     5.26 GHz    39.09 cycles/value   148.87 ins./value     3.81 i/c
    dom_get_int64                :     0.21 ns/value    65.48 GB/s     5.16 GHz     1.06 cycles/value     8.00 ins./value     7.52 i/c
  19 digits:
    ondemand_get_int64           :    10.65 ns/value     1.93 GB/s     5.25 GHz    55.86 cycles/value   212.58 ins./value     3.81 i/c
    dom_get_int64                :     0.20 ns/value   100.90 GB/s     5.16 GHz     1.05 cycles/value     8.00 ins./value     7.63 i/c

double:

Trial 1:
  5 digits:
    ondemand_get_double          :    11.53 ns/value     1.00 GB/s     5.17 GHz    59.58 cycles/value   162.17 ins./value     2.72 i/c
    dom_get_double               :     0.57 ns/value    20.25 GB/s     5.29 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c
  12 digits:
    ondemand_get_double          :    11.45 ns/value     1.62 GB/s     5.13 GHz    58.68 cycles/value   234.38 ins./value     3.99 i/c
    dom_get_double               :     0.57 ns/value    32.43 GB/s     5.27 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c
  19 digits:
    ondemand_get_double          :    18.79 ns/value     1.36 GB/s     5.15 GHz    96.72 cycles/value   346.49 ins./value     3.58 i/c
    dom_get_double               :     0.57 ns/value    45.02 GB/s     5.31 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c

Trial 2:
  5 digits:
    ondemand_get_double          :    11.33 ns/value     1.01 GB/s     5.26 GHz    59.57 cycles/value   162.17 ins./value     2.72 i/c
    dom_get_double               :     0.57 ns/value    20.13 GB/s     5.26 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c
  12 digits:
    ondemand_get_double          :    11.43 ns/value     1.62 GB/s     5.14 GHz    58.70 cycles/value   234.38 ins./value     3.99 i/c
    dom_get_double               :     0.57 ns/value    32.46 GB/s     5.28 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c
  19 digits:
    ondemand_get_double          :    18.62 ns/value     1.37 GB/s     5.21 GHz    97.05 cycles/value   346.49 ins./value     3.57 i/c
    dom_get_double               :     0.56 ns/value    45.32 GB/s     5.35 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c

Trial 3:
  5 digits:
    ondemand_get_double          :    11.56 ns/value     1.00 GB/s     5.22 GHz    60.31 cycles/value   162.17 ins./value     2.69 i/c
    dom_get_double               :     0.56 ns/value    20.44 GB/s     5.35 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c
  12 digits:
    ondemand_get_double          :    11.32 ns/value     1.64 GB/s     5.21 GHz    59.01 cycles/value   234.38 ins./value     3.97 i/c
    dom_get_double               :     0.56 ns/value    32.82 GB/s     5.34 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c
  19 digits:
    ondemand_get_double          :    18.60 ns/value     1.37 GB/s     5.23 GHz    97.30 cycles/value   346.49 ins./value     3.56 i/c
    dom_get_double               :     0.56 ns/value    45.27 GB/s     5.35 GHz     3.01 cycles/value     8.00 ins./value     2.66 i/c

number:

Trial 1:
  5 digits:
    ondemand_get_number          :    13.25 ns/value     0.68 GB/s     5.18 GHz    68.67 cycles/value   158.98 ins./value     2.31 i/c
  12 digits:
    ondemand_get_number          :    13.52 ns/value     1.18 GB/s     5.18 GHz    70.03 cycles/value   201.63 ins./value     2.88 i/c
  19 digits:
    ondemand_get_number          :    79.87 ns/value     0.29 GB/s     5.23 GHz   417.54 cycles/value  1423.02 ins./value     3.41 i/c

Trial 2:
  5 digits:
    ondemand_get_number          :    13.07 ns/value     0.69 GB/s     5.23 GHz    68.41 cycles/value   158.98 ins./value     2.32 i/c
  12 digits:
    ondemand_get_number          :    13.43 ns/value     1.19 GB/s     5.23 GHz    70.23 cycles/value   201.63 ins./value     2.87 i/c
  19 digits:
    ondemand_get_number          :    79.72 ns/value     0.29 GB/s     5.16 GHz   411.74 cycles/value  1423.02 ins./value     3.46 i/c

Trial 3:
  5 digits:
    ondemand_get_number          :    13.02 ns/value     0.69 GB/s     5.23 GHz    68.11 cycles/value   158.98 ins./value     2.33 i/c
  12 digits:
    ondemand_get_number          :    13.40 ns/value     1.19 GB/s     5.23 GHz    70.10 cycles/value   201.63 ins./value     2.88 i/c
  19 digits:
    ondemand_get_number          :    79.52 ns/value     0.29 GB/s     5.23 GHz   415.98 cycles/value  1423.02 ins./value     3.42 i/c

CPU: AMD Ryzen 5 7600X (6cores)
Governor: Performance
Boost: ON
Pin Freq: [5457105..5457105]

Closes #2186

Happy to change anything based on your feedback !!

benchmark have compiler flags to choose which one to run (same method as benchmark/dom/parse.cpp)
use same benchmarking process as car_builder (with event_counter.h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_int64() can be slower than get_double()?

1 participant