From 8ddda7fc3e9f424a51f590bc6d87bbd2ff5cdcb1 Mon Sep 17 00:00:00 2001
From: Niels Lohmann
Date: Mon, 23 Nov 2026 16:24:50 +0100
Subject: [PATCH] docs: blog post: remeasure on develop 322063822f as the
3.13.0 candidate
Measured again on November 23 with develop 322063822f standing in for
3.13.0: the suite on the M1 Max (3.3x, 184 benchmarks) and on the Intel
MacBook Pro (now 3.3x), the timeline (the 28 commits since November 7 and
twelve earlier ones as a check; #6031 is now a commit, not a pending
step), the compile times, the stream gap, the allocator check, Appendix D
(9 runs), and the comparison on the Mac and on x86-64 (three runs per
compiler there), with the held-out files and JSONTestSuite.
Describe the performance-relevant pull requests merged since then:
JSON_RECURSION_DEPTH_LIMIT (#6081), forced inlining only in optimized
builds (#6117), and the two quadratic cases of #5886 that #6076 and
#6077 fixed before the release.
Signed-off-by: Niels Lohmann
---
.../docs/home/blog/how_3_13_0_got_faster.md | 1219 +--
docs/mkdocs/docs/images/perf_blog_cliffs.svg | 74 +-
.../docs/images/perf_blog_distribution.svg | 24 +-
docs/mkdocs/docs/images/perf_blog_heldout.svg | 108 +-
.../mkdocs/docs/images/perf_blog_overview.svg | 66 +-
docs/mkdocs/docs/images/perf_blog_price.svg | 92 +-
.../perf_blog_timeline_accept_twitter.svg | 70 +-
.../images/perf_blog_timeline_dump_canada.svg | 32 +-
.../perf_blog_timeline_dump_twitter.svg | 42 +-
.../perf_blog_timeline_from_cbor_twitter.svg | 56 +-
.../perf_blog_timeline_parse_canada.svg | 72 +-
.../images/perf_blog_timeline_parse_citm.svg | 70 +-
...f_blog_timeline_parse_twitter_ifstream.svg | 32 +-
.../perf_blog_timeline_to_cbor_twitter.svg | 40 +-
.../docs/images/perf_blog_usecases_mac.svg | 288 +-
.../images/perf_blog_usecases_x86-clang.svg | 342 +-
.../images/perf_blog_usecases_x86-gcc.svg | 272 +-
.../images/perf_blog_usecases_x86-gcc13.svg | 296 +-
.../figures/data/perf_heldout_validate.json | 1652 ++--
.../scripts/figures/data/perf_suite.csv | 366 +-
.../scripts/figures/data/perf_timeline.csv | 29 +-
.../figures/data/perf_usecases_mac.json | 7676 ++++++++---------
.../figures/data/perf_usecases_x86-clang.json | 6286 +++++++-------
.../figures/data/perf_usecases_x86-gcc.json | 6204 ++++++-------
.../figures/data/perf_usecases_x86-gcc13.json | 6520 +++++++-------
docs/mkdocs/scripts/figures/perf_blog.py | 63 +-
26 files changed, 16023 insertions(+), 15968 deletions(-)
diff --git a/docs/mkdocs/docs/home/blog/how_3_13_0_got_faster.md b/docs/mkdocs/docs/home/blog/how_3_13_0_got_faster.md
index e13fd94a8..ae0773d11 100644
--- a/docs/mkdocs/docs/home/blog/how_3_13_0_got_faster.md
+++ b/docs/mkdocs/docs/home/blog/how_3_13_0_got_faster.md
@@ -3,16 +3,16 @@
-
+
Since 2016, the [README](https://github.com/nlohmann/json#readme) of this library has said this about speed:
@@ -20,12 +20,12 @@ Since 2016, the [README](https://github.com/nlohmann/json#readme) of this librar
> JSON support with a single header, then this library is the way to go.
That sentence is still true, but the gap is a lot smaller now. Swap the 3.12.0 header for the 3.13.0 one, recompile, and
-the 182 benchmarks of the library's own suite run 3.3× as fast on an Apple M1 Max (geometric mean; 3.1× on an Intel
-MacBook Pro from 2016). Not a line of your code changes. Parsing typical documents got 3.5–5.1× as fast, and writing
+the 184 benchmarks of the library's own suite run 3.3× as fast on an Apple M1 Max (geometric mean; 3.3× on an Intel
+MacBook Pro from 2016). Not a line of your code changes. Parsing typical documents got 3.5–5.0× as fast, and writing
them 2.9–6.6×. The new version also adds [`json_document`](../../features/json_view/index.md), a second way to hold a parsed
document, which competes with the fastest C++ and Rust JSON libraries; [How it compares](#how-it-compares) has the
-numbers, including where it loses. The price is compile time: two small example programs take 36–68% longer to compile.
-A precompiled header or a C++20 module wins back most or all of that in debug builds, and 41% to all of it in
+numbers, including where it loses. The price is compile time: two small example programs take 41–64% longer to compile.
+A precompiled header or a C++20 module wins back most or all of that in debug builds, and 42–93% of it in
optimized builds ([The price](#the-price)).
This post is about *how*. Hardly any of the techniques are new: we borrowed them from
@@ -64,19 +64,19 @@ A](#a-test-files) says what makes each of them hard.
new one, Google Benchmark suite on an Apple M1 Max, median of 12 runs. More is better; the vertical line at 1× is
3.12.0. The times are in [Appendix B](#b-3120-against-3130).
-The rows above are chosen to show the range. All 182 benchmarks of the suite:
+The rows above are chosen to show the range. All 184 benchmarks of the suite:
--8<-- "images/perf_blog_distribution.svg"
-
How many of the suite's 182 benchmarks got how much faster. The two below 1× copy
-`citm_catalog.json` and `twitter.json` without destroying the copy (0.95× and 0.99×). Every row is in [Appendix
+
How many of the suite's 184 benchmarks got how much faster. The two below 1× copy
+`citm_catalog.json` and `twitter.json` without destroying the copy (0.94× and 0.97×). Every row is in [Appendix
B](#b-3120-against-3130).
-The median benchmark got 2.9× as fast. On an Intel MacBook Pro (Skylake), the median is 2.9× as well, but parsing
-floating-point numbers gained more (`canada.json` 6.1× instead of 4.1×) and writing integers less (`dump()` 1.4–2.3×
-instead of 2.2–3.7×); [Appendix B](#b-3120-against-3130) has both columns. Copying and comparing values gained the
+The median benchmark got 3.0× as fast. On an Intel MacBook Pro (Skylake), the median is 3.1×, but parsing
+floating-point numbers gained more (`canada.json` 7.1× instead of 4.0×) and writing integers less (`dump()` 1.5–2.2×
+instead of 2.2–3.8×); [Appendix B](#b-3120-against-3130) has both columns. Copying and comparing values gained the
least, and the largest gains come from fixing algorithms rather than tuning them (theme
7).
@@ -106,8 +106,8 @@ Eight themes did most of the work:
## Where the time went: a timeline
The suite compares two points. To see which change did what, we compiled one small benchmark against the header of each
-of the 358 commits on `develop` that changed `json.hpp` or `json_view.hpp` from 3.12.0 to November 7, and of 3.13.0, and
-ran all of them interleaved. Four of the eight workloads we followed:
+of the 386 commits on `develop` that changed `json.hpp` or `json_view.hpp` from 3.12.0 to 3.13.0, and ran all of them
+interleaved. Four of the eight workloads we followed:
- `parse()` of `citm_catalog.json`: the lexer's structure and whitespace handling, and building many small objects;
- `parse()` of `canada.json`: converting text to floating-point numbers;
@@ -133,8 +133,8 @@ larger steps mean something.
-
Speedup over 3.12.0 after each of the 358 commits that changed the headers up to November
-7, from 3.12.0 (left) to 3.13.0 (right). More is better; each point is the median of 4 runs of one build, taken in
+
Speedup over 3.12.0 after each of the 386 commits that changed the headers, from 3.12.0
+(left) to 3.13.0 (right). More is better; each point is the median of 4 runs of one build, taken in
random order (with 4 runs, the mean of the two middle ones). The badges are theme numbers; "U" is a UTF-8 check that
came and went. The other four workloads, and every labeled step with its pull request and size, are in [Appendix
C](#c-the-timeline).
@@ -320,7 +320,7 @@ exactly what the lexer consumes, so the stream is left where it was before. On a
`std::ifstream` took 1.8–2.5× as long as reading the file into a string and parsing that, in the pull request's
measurement before the change, and 9–16% longer after it. Since then, parsing a string got faster still, because the
fused parser of [One loop instead of two](#one-loop-instead-of-two) needs input in one block of memory, so a stream now
-takes 25–38% longer than the string again (the file read with one `read()`, parsing `twitter.json`,
+takes 22–37% longer than the string again (the file read with one `read()`, parsing `twitter.json`,
`citm_catalog.json`, and `canada.json`).
### `FILE*`
@@ -803,9 +803,9 @@ was parsed. Now all open arrays share one stack of elements; when an array of up
at its exact size from a range of move iterators, one allocation. `ordered_json` objects collect up to 32 members the
same way, with a linear duplicate-key check over that short slice, and larger objects get a side table of hashes for
that check from 64 members on. An `ordered_json` object with very many members went from 43 million instructions to 1.9
-million, and `ordered_json` now parses 1–15% *faster* than `json` in our suite, since `json`'s `std::map` still
-allocates a node per member. The binary readers know their sizes up front and use a separate handler without the stack;
-sharing it had made them 5–12% slower with GCC.
+million, and `ordered_json` now parses 7–13% *faster* than `json` in our suite (and as fast on `canada.json`), since
+`json`'s `std::map` still allocates a node per member. The binary readers know their sizes up front and use a separate
+handler without the stack; sharing it had made them 5–12% slower with GCC.
The binary readers also stopped taking every element through their general dispatch. When an array opens, the CBOR and
MessagePack readers read the numbers, booleans, and nulls that follow in one loop, and the UBJSON and BJData readers do
@@ -952,6 +952,10 @@ Inlining is a budget per function. Once the string writer had grown, GCC 13 and
helpers into the pretty-printing loop, and indented output got up to 13% slower. They are now forced inline. A change in
one place silently made an unrelated loop slower; only a benchmark of indented output noticed.
+Forcing has a cost of its own. At `-O0`, every forced copy of a helper gets its own stack slots, and the recursive frame
+of `dump()` grew from 480 bytes in 3.12.0 to 2,304 bytes with Clang. The serializer's helpers are now forced inline only
+in optimized builds ([#6117][6117]); at `-O2`, the machine code is byte for byte the same as before.
+
### Branches the compiler chose
[`json_document`](../../api/json_document.md) writes most floats of `canada.json` by deciding, from where the `double`
@@ -1144,7 +1148,7 @@ save more registers, once per nested value, which cost `citm_catalog.json` 13%.
None of the micro-optimizations above matter much next to an algorithm that is quadratic. Seven operations were
quadratic or worse in 3.12.0. They are fixes of cases most programs never hit, not tuning, so they are not part of the
-3.0× above (except `flatten()`, which the suite happens to measure); [Appendix D](#d-algorithmic-fixes) has the numbers:
+3.3× above (except `flatten()`, which the suite happens to measure); [Appendix D](#d-algorithmic-fixes) has the numbers:
--8<-- "images/perf_blog_cliffs.svg"
@@ -1211,6 +1215,13 @@ slower, because `std::map`'s own copy clones its tree without comparing a single
counter: converting a value from another `basic_json` specialization, the ordering comparisons (`<`, `<=>` and the
operators derived from them), and equality for custom container types, whose own `operator==` calls ours.
+128 is only the default. 128 recursive levels of `dump()` need about 290 KiB of stack in a debug build with Clang, more
+than a thread with a small stack has (musl gives a thread 128 KiB), so
+[`JSON_RECURSION_DEPTH_LIMIT`](../../api/macros/json_recursion_depth_limit.md) sets the limit from 0 to 254
+([#6081][6081]). With 0, every walk uses its explicit stack from the first level and needs 16 KiB of stack or less; in
+the pull request's measurement, ordinary documents then took 1.1–2.4× as long, while a limit of 16 already cost nothing
+measurable.
+
### Destroying without a stack
The destructor's walk for deep values uses pointer reversal, the idea behind the [Schorr-Waite graph marking
@@ -1219,9 +1230,20 @@ holds the link back to the container's parent, so the way back needs no memory (
shows the loop). The walk allocates nothing and calls nothing that can throw, which fixed two older bugs: the previous
destructor flattened children into a `std::vector`, which ignored the allocator type and could let `std::bad_alloc`
escape from a `noexcept` destructor. A test checks with a counting allocator that destroying any value allocates
-nothing. Against 3.12.0, destroying a parsed document is 1.24–1.55× as fast in our suite, and destroying an array of one
+nothing. Against 3.12.0, destroying a parsed document is 1.23–1.55× as fast in our suite, and destroying an array of one
million small objects 1.39×.
+### Two cliffs of our own
+
+New algorithms bring their own worst cases. [#5886][5886] sped up `unflatten()` by keeping the prefixes that become
+arrays in a hash set of key slices, and `patch()` by resuming each operation from the path it shares with the previous
+one. Both lookups compared whole prefixes, which made them quadratic in the length of a single key or path, where 3.12.0
+was linear: on `develop`, an `unflatten()` of one key of 100,000 `/0` tokens took 2.4 seconds, and two `test` operations
+whose paths of 200,000 tokens share the first 100,000 took 1.2 seconds. [#6076][6076] and [#6077][6077] made both linear
+again before the release. The patch is now 4.4× as fast as with 3.12.0 (2.4 against 10.6 ms); `unflatten()` of the long
+key still takes 1.7× as long (12.2 against 7.3 ms), the price of the tree of long prefixes that lets the result ignore
+the key order.
+
## 8 Build a different data structure { #theme-8 }
After all of the above, [`json::parse()`](../../api/basic_json/parse.md) is still bound by what it builds: one heap
@@ -1382,12 +1404,12 @@ operating system. It is not neutral in every detail, though:
- The string has 64 bytes of spare capacity, so simdjson, which reads up to 64 bytes past the end, can use it without a
copy. A program would load the file into such a buffer in the first place.
- yyjson, RapidJSON, and simd-json can parse in place, which changes the buffer. So every call gets a fresh copy of the
- string, and the copy counts toward their time: 11–14 µs for `twitter.json` on the Mac, and 30–46 µs on x86-64, where
+ string, and the copy counts toward their time: about 9 µs for `twitter.json` on the Mac, and 44–60 µs on x86-64, where
fresh memory costs page faults. yyjson's normal read makes the same copy internally, which is why both ways take about
as long. A server that validates a request and then passes it on needs the copy. A program that reads a file into a
buffer it owns can skip it, so we also timed the in-place ways with the copy made before the timer starts. On the Mac,
- yyjson then comes 3–5% closer, and on `twitter.json` it validates and selects 1–2% faster than `json_document`. On
- x86-64, it ties `json_document` in *sum* with Clang and takes 1.04× and 1.15× its time with GCC 16 and GCC 13.
+ yyjson then comes 3–4% closer, and on `twitter.json` it selects 1.5% faster than `json_document` and sums as fast. On
+ x86-64, it ties `json_document` in *sum* with Clang and takes 1.05× and 1.16× its time with GCC 16 and GCC 13.
- `json_document` reads the string in place and keeps pointing into it. A document that owns its text
([`parse_copy()`](../../api/basic_json_document/parse_copy.md)) costs one copy more: 3–5% on the Mac.
- Reading from files and streams is not part of the comparison.
@@ -1439,24 +1461,24 @@ lists only x86-64 Linux; we show it on the Mac anyway.
On the Apple M1 Max, among the ways that reject all four broken inputs, `json_document` has the lowest mean on the four
files in all six use cases, and yyjson is the next library in every column; in *validate*, `json::accept()` comes in
-between (1.38× against yyjson's 1.41×). That includes editing, where the editable document is
+between (1.40× against yyjson's 1.42×). That includes editing, where the editable document is
faster than yyjson's mutable document: the speed doesn't depend on being read-only.
Some caveats belong next to that:
-- **The lead is not the same on every file.** On `twitter.json`, yyjson is within 4–7% in *validate*, *sum*, and
+- **The lead is not the same on every file.** On `twitter.json`, yyjson is within 5–7% in *validate*, *sum*, and
*select*. Most of the lead comes from `citm_catalog.json`, the floats of `canada.json` (next point) and the size of
`jeopardy.json`.
- **Floats are converted only when read.** That helps `json_document` in *validate* and *select* on `canada.json`, where
most others convert 111,080 floats nobody looks at. Libraries that can skip the conversion use that mode there, but
- only Boost.JSON gains much: it validates `canada.json` in 47% of the time. *sum* reads every number, so it is the fair
+ only Boost.JSON gains much: it validates `canada.json` in 48% of the time. *sum* reads every number, so it is the fair
comparison for floats; there, `json_document` is still slightly ahead of yyjson.
- **Checking less pays in *select*.** If the input needn't be checked fully, simdjson's On-Demand API and Glaze reading
- into structs select in 0.76× and 0.81× `json_document`'s time (Glaze is faster only on `citm_catalog.json` and
+ into structs select in 0.76× and 0.83× `json_document`'s time (Glaze is faster only on `citm_catalog.json` and
`canada.json`), and in 0.55–0.61× on x86-64: the right halves of the *select* column.
- **Indentation.** Two of the four files are indented, which theme
2 helps. On minified copies of `twitter.json` and
- `citm_catalog.json`, yyjson comes closer in *sum* (1.11 → 1.01) and a little in *validate* (1.27 → 1.24), and
+ `citm_catalog.json`, yyjson comes closer in *sum* (1.11 → 1.03) and hardly in *validate* (1.27 → 1.26), and
`json_document` stays first.
- **Number text can be copied.** With [`number_format::source`](../../api/basic_json_view/number_format.md),
`json_document` writes each number by copying its text instead of formatting it, and yyjson and RapidJSON can read
@@ -1464,15 +1486,15 @@ Some caveats belong next to that:
minifier needs. It makes writing `canada.json` with `json_document` 4.1× as fast and minifying it 1.9× as fast; the
"N" halves of *edit*, *minify*, and *write* show it.
- **Small documents.** On a 2.5 KB message, the fastest libraries take about a microsecond on the Mac and 1.1–2 on
- x86-64. yyjson validates and sums it as fast as `json_document` on the Mac, and with GCC on x86-64, simdjson and
- yyjson sum it as fast.
+ x86-64. yyjson sums it 4% faster than `json_document` on the Mac and validates it in 1.06× its time, and with GCC on
+ x86-64, simdjson and yyjson sum it about as fast.
### Reading into structs
A view can be converted into your own types with the same [`from_json()`](../../features/arbitrary_types.md) as `json`,
including the ones the [`NLOHMANN_DEFINE_TYPE_*`](../../api/macros/nlohmann_define_type_non_intrusive.md) macros
generate. That is as fast as picking the fields by hand from the view; only for the many small records of
-`jeopardy.json` does it take 22% longer. On the Mac, Glaze, serde_json, and Boost.JSON's `parse_into`, reading into the
+`jeopardy.json` does it take 24% longer. On the Mac, Glaze, serde_json, and Boost.JSON's `parse_into`, reading into the
same structs and checking everything, take 1.7×, 2.3×, and 3.1× as long (geometric mean over the four files). On a
`json` value, reading into the structs takes about as long as `json::parse()` alone.
@@ -1481,15 +1503,15 @@ same structs and checking everything, take 1.7×, 2.3×, and 3.1× as long (geom
And nlohmann/json without `json_document`? `json` builds a tree of separate allocations, and it shows: for *select*,
*edit*, and *minify* it takes several times as long as `json_document`, like Boost.JSON and RapidJSON. Where no tree is
needed, the fused parser ([One loop instead of two](#one-loop-instead-of-two)) puts it among the fastest:
-[`json::accept()`](../../api/basic_json/accept.md) validates the four files in 1.38× `json_document`'s time on the Mac,
-ahead of every other library, and a SAX handler sums them in 1.34×, behind only yyjson and simdjson. Boost.JSON takes
+[`json::accept()`](../../api/basic_json/accept.md) validates the four files in 1.40× `json_document`'s time on the Mac,
+ahead of every other library, and a SAX handler sums them in 1.35×, behind only yyjson and simdjson. Boost.JSON takes
1.8× and 1.5× as long as `json` there, and 1.2–1.4× and 1.1–1.3× on x86-64. `dump()` writes faster than Boost.JSON,
RapidJSON and serde_json, and about as fast as Glaze.
Much of Boost.JSON's lead in building a tree comes from its allocator: here it builds the tree in a
-`monotonic_resource`, an arena that is freed in one go, which saves it 27–40%. With its default allocator, which
+`monotonic_resource`, an arena that is freed in one go, which saves it 30–41%. With its default allocator, which
allocates every string, array, and object on its own as `json` does, `boost::json::parse()` with precise numbers takes
-13–17% longer than `json::parse()` on `twitter.json`, 19–20% longer on `citm_catalog.json`, and 2% less time on
+11% longer than `json::parse()` on `twitter.json`, 19% longer on `citm_catalog.json`, and about as long (1% longer) on
`canada.json` (on the Mac, freeing the tree included).
### Results on x86-64
@@ -1509,33 +1531,33 @@ the figure above. Less is better; hover over or tap a cell for the times and the
23 are in [Appendix E](#e-comparison-with-other-libraries).
`json_document` has the lowest mean in five of the six columns with every compiler. The exception is *sum*, where
-simdjson is ahead with GCC, and `json` with a SAX handler with GCC 13 and Clang 23 (with Clang by 5%, all of it on
-`jeopardy.json`; below). This machine is noisy, though: between two runs, a library's time relative to
-`json_document`'s moved by up to 7–8% (95th percentile; 2.4% on the Mac), so a lead of 5% is no result. In *validate*,
-the next library takes 1.8–2.0× as long, or 1.6–1.7× if every library may reuse its parser, because validating no
-longer builds an index (theme 8). The only way in between is
-`json::accept()` at 1.3–1.7×, which builds nothing either ([One loop instead of two](#one-loop-instead-of-two)).
-Behind those means, `json_document` loses on single files:
+simdjson is ahead with GCC (and sonic-rs, by 1%, with GCC 13), and `json` with a SAX handler with GCC 13 and Clang 23
+(with Clang by 5%, all of it on `jeopardy.json`; below). This machine is noisy, though: between two runs, a library's
+time relative to `json_document`'s moved by up to 9–11% (95th percentile; 3.0% on the Mac), so a lead of 5% is no
+result. In *validate*, the next library takes 1.8–1.9× as long, or 1.6–1.7× if every library may reuse its parser,
+because validating no longer builds an index (theme 8). The only
+way in between is `json::accept()` at 1.4–1.7×, which builds nothing either ([One loop instead of
+two](#one-loop-instead-of-two)). Behind those means, `json_document` loses on single files:
- **One pass over every value, with GCC.** simdjson's On-Demand API sums all numbers of `twitter.json`,
- `citm_catalog.json`, and `canada.json` in 0.76–0.97× `json_document`'s time with GCC 16 (0.79–0.92× with GCC 13). With
+ `citm_catalog.json`, and `canada.json` in 0.75–0.92× `json_document`'s time with GCC 16 (0.73–0.94× with GCC 13). With
Clang, `json_document` is ahead there, except on `canada.json`, where yyjson, which converts the floats during the
parse, is faster than converting them on access, and on `citm_catalog.json`, where `json`'s SAX handler and
- Boost.JSON's are 1–3% faster.
+ Boost.JSON's are 2% faster.
- **Fresh large documents.** For the 56 MB `jeopardy.json`, a fresh document needs a fresh 52 MB index, and on Linux the
page faults of that much new memory are a large part of the time: copying the file into fresh memory alone takes about
50% as long as `json_document`'s parse. Boost.JSON's SAX parser and sonic-rs, which build nothing, sum it in
- 0.64–0.71× the time, and `json`'s SAX handler in 0.70–0.75×. Reusing the document cuts `json_document`'s time by
- 41–43%, to 51 ms, less than sonic-rs's 60 ms. Validating needs no index: `json_document::accept()` takes 33–35 ms,
- `json::accept()` 39–40 ms, and no other library validates `jeopardy.json` faster, even reused (the next is simdjson's
- reused parser at 48–52 ms). On the Mac, a fresh document costs hardly more than a reused one.
-- **Writing floats.** yyjson writes `canada.json` in 0.84–0.93× the time (and Glaze with GCC 13 and `json`'s `dump()`
- with GCC 16, which start from `double`s, in 0.98× and 0.99×), because `json_document` first converts most floats from
- their text. Writing the source text instead (`number_format::source`, the "N" half) avoids that.
-- **simdjson's DOM.** It selects from `citm_catalog.json` 19% faster with GCC 16 and 7–13% faster with GCC 13 and Clang
- 23, and from `twitter.json` 2–4% faster with GCC. Boost.JSON, Glaze, sonic-rs, sonic-cpp, and yyjson are ahead in a
- few more cells, by 1–10%: summing `citm_catalog.json` (Boost.JSON with GCC), and selecting from or writing
- `jeopardy.json`. Most of that is within the noise.
+ 0.62–0.72× the time, and `json`'s SAX handler in 0.70–0.80×. Reusing the document cuts `json_document`'s time by
+ 39–40%, to 54–56 ms, slightly less than sonic-rs's 57 ms. Validating needs no index: `json_document::accept()` takes
+ 35–37 ms, `json::accept()` 38–43 ms, and no other library validates `jeopardy.json` faster, even reused (the next are
+ simdjson's reused parser and sonic-rs at 48–53 ms). On the Mac, a fresh document costs hardly more than a reused one.
+ - **Writing floats.** yyjson writes `canada.json` in 0.87–0.96× the time (and Glaze with GCC 13 and `json`'s `dump()`
+ with GCC 16, which start from `double`s, in 0.96× and 1.00×), because `json_document` first converts most floats from
+ their text. Writing the source text instead (`number_format::source`, the "N" half) avoids that. - **simdjson's DOM.**
+ It selects from `citm_catalog.json` 20% faster with GCC 16 and 8–12% faster with GCC 13 and Clang 23, and from
+ `twitter.json` 2% faster with GCC 16. Boost.JSON, Glaze, sonic-cpp, and yyjson are ahead in a few more cells, by
+ 1–10%: summing `citm_catalog.json` (Boost.JSON), selecting from `jeopardy.json` (Glaze) or writing it (sonic-cpp with
+ Clang), and summing or selecting from the minified `citm_catalog.json` (yyjson). Most of that is within the noise.
The full tables, with each library's variants, are in [Appendix E](#e-comparison-with-other-libraries).
@@ -1544,8 +1566,8 @@ The full tables, with each library's variants, are in [Appendix E](#e-comparison
The four files are the ones 3.13.0 was tuned on, so we also ran *validate*, *sum*, *minify*, and *write* on the 19 other
files of simdjson's [`jsonexamples`](https://github.com/simdjson/simdjson-data/tree/master/jsonexamples). By geometric
mean, `json_document` stays the fastest in *validate*, *minify*, and *write* on every compiler, and in *sum* with Clang
-and on the Mac; with GCC, simdjson sums in 0.87–0.88× its time. `json::accept()` validates them in 1.4–1.6× the time
-of `json_document` on x86-64, close to simdjson (1.44–1.46×), the fastest other library. File by file, for *validate*:
+and on the Mac; with GCC, simdjson sums in 0.86–0.87× its time. `json::accept()` validates them in 1.4–1.6× the time
+of `json_document` on x86-64, close to simdjson (1.43–1.46×), the fastest other library. File by file, for *validate*:
--8<-- "images/perf_blog_heldout.svg"
@@ -1555,10 +1577,10 @@ of `json_document` on x86-64, close to simdjson (1.44–1.46×), the fastest oth
fastest other library's, per file; below 1.0× it is the fastest. Less is better. The right column names the next library
on x86-64 (GCC 16.2).
-`json_document` validates 18 of the 19 files fastest with GCC 16, Clang 23, and on the Mac: simdjson ties on
-`google_maps_api_response` with GCC 16, Boost.JSON on `mesh.pretty` with Clang 23, and simdjson validates
-`apache_builds` 7% faster on the Mac. With GCC 13 it is 17: simdjson validates `google_maps_api_response` 6% faster,
-and Boost.JSON `mesh.pretty` 10% faster (1% in the first of our two runs on November 7). Before validating
+`json_document` validates all 19 files fastest with GCC 16 and Clang 23, though simdjson comes within 2% on
+`google_maps_api_response` with GCC 16 and within 1% on `tree-pretty` with Clang 23. On the Mac and with GCC 13 it is
+18: simdjson validates `apache_builds` 9% faster on the Mac, and Boost.JSON validates `mesh.pretty` 1% faster with GCC
+13. Before validating
without an index (theme 8) and skipping fraction digits 16 bytes
at a time (theme 2), Boost.JSON validated the number-heavy files
up to 1.5× as fast on x86-64.
@@ -1593,8 +1615,8 @@ the pull requests that tried them.
## The price
-None of this is free at compile time. `json.hpp` grew from 25,526 to 48,025 lines (`json_view.hpp` is a separate header
-of 11,909 lines that you only pay for if you include it). To see what that means for a program, we compiled two small
+None of this is free at compile time. `json.hpp` grew from 25,526 to 49,106 lines (`json_view.hpp` is a separate header
+of 12,053 lines that you only pay for if you include it). To see what that means for a program, we compiled two small
ones with both versions:
- `count_numbers` reads `twitter.json` and adds up all of its numbers, like the *sum* use case in [How it
@@ -1614,16 +1636,16 @@ better: Apple clang 21 and GCC 16.2, CPU time of the compiler, median of 5 inter
one-off cost of building the precompiled header or the module is not included. Hover over a bar for the time in
milliseconds; [Appendix G](#g-how-we-measured) has all times, the programs, and the commands.
-3.13.0 takes 36–68% longer to compile these programs. A good part of that is reading the header, and a precompiled
+3.13.0 takes 41–64% longer to compile these programs. A good part of that is reading the header, and a precompiled
header or a module does that once instead of in every translation unit:
- **In debug builds,** which are what you wait for while you edit, a precompiled 3.13.0 compiles faster than 3.12.0 with
- Apple clang, and within 12–15% of it with GCC.
+ Apple clang, and within 10–13% of it with GCC.
- **In optimized builds,** less of the increase goes away, because the optimizer still works through all the code a
- program instantiates. A precompiled header or a module wins back 41% to all of it.
-- **The one-off cost** is 0.9 s (Apple clang) or 2.3 s (GCC) to build the precompiled header, and 1.4 s or 2.3 s to
+ program instantiates. A precompiled header or a module wins back 42–93% of it.
+- **The one-off cost** is 0.9 s (Apple clang) or 2.5 s (GCC) to build the precompiled header, and 1.5–1.6 s or 2.4 s to
build the module, once per set of compiler flags. A precompiled header pays for itself after two to four translation
- units, a module after three to six.
+ units, a module after three to five.
- **Modules have caveats.** Apple clang needs `-fcxx-modules`, [module support](../../features/modules.md) still depends
heavily on the compiler version, and macros don't cross a module boundary: with `import nlohmann.json;`, the
`NLOHMANN_DEFINE_TYPE_*` macros aren't available, which is why `server_config` writes `to_json()` and `from_json()` by
@@ -1718,216 +1740,218 @@ The rows of the first chart:
| workload | 3.12.0 | 3.13.0 | speedup | Intel |
| --- | --: | --: | --: | --: |
-| `json::parse()` of `twitter.json` | 3.21 ms | 0.921 ms | 3.5× | 2.6× |
-| `json::parse()` of `citm_catalog.json` | 7.40 ms | 1.45 ms | 5.1× | 3.5× |
-| `json::parse()` of `canada.json` | 15.2 ms | 3.73 ms | 4.1× | 6.1× |
-| `json::parse()` of `canada.json`, indented by 4 spaces | 34.2 ms | 4.61 ms | 7.4× | 8.0× |
-| `ordered_json::parse()` of `citm_catalog.json` | 11.0 ms | 1.34 ms | 8.2× | 6.6× |
-| `json::parse()` of `twitter.json` from an `std::ifstream` | 3.40 ms | 1.38 ms | 2.5× | 2.3× |
-| `json::parse()` of `citm_catalog.json` from a `FILE*` | 35.0 ms | 2.34 ms | 14.9× | 5.7× |
-| `json::accept()` of `citm_catalog.json` | 6.48 ms | 0.474 ms | 13.7× | 8.4× |
-| `dump()` of `twitter.json` | 1.41 ms | 0.214 ms | 6.6× | 5.7× |
-| `dump()` of `canada.json` | 6.71 ms | 2.31 ms | 2.9× | 3.3× |
-| `dump(4)` of `citm_catalog.json` | 1.95 ms | 0.422 ms | 4.6× | 4.1× |
-| `to_cbor()` of `twitter.json` | 0.637 ms | 0.144 ms | 4.4× | 6.7× |
-| `from_cbor()` of `twitter.json` from memory | 3.09 ms | 0.879 ms | 3.5× | 2.8× |
-| `from_cbor()` of `twitter.json` from a `FILE*` | 9.92 ms | 1.07 ms | 9.2× | 6.5× |
-| `diff()` of `canada.json` with every eighth scalar changed | 39.2 ms | 3.75 ms | 10.4× | 11.2× |
-| iterating over every value of `canada.json` | 0.874 ms | 0.445 ms | 2.0× | 2.0× |
-| copying `citm_catalog.json` and destroying the copy | 1.65 ms | 1.49 ms | 1.11× | 1.12× |
-| `==` of `citm_catalog.json` and a copy | 0.264 ms | 0.261 ms | 1.01× | 0.95× |
+| `json::parse()` of `twitter.json` | 3.19 ms | 0.902 ms | 3.5× | 2.9× |
+| `json::parse()` of `citm_catalog.json` | 7.31 ms | 1.45 ms | 5.0× | 4.0× |
+| `json::parse()` of `canada.json` | 15.1 ms | 3.73 ms | 4.0× | 7.1× |
+| `json::parse()` of `canada.json`, indented by 4 spaces | 33.7 ms | 4.55 ms | 7.4× | 8.5× |
+| `ordered_json::parse()` of `citm_catalog.json` | 10.9 ms | 1.34 ms | 8.1× | 8.2× |
+| `json::parse()` of `twitter.json` from an `std::ifstream` | 3.35 ms | 1.36 ms | 2.5× | 2.3× |
+| `json::parse()` of `citm_catalog.json` from a `FILE*` | 34.8 ms | 2.34 ms | 14.9× | 10.3× |
+| `json::accept()` of `citm_catalog.json` | 6.38 ms | 0.474 ms | 13.5× | 14.6× |
+| `dump()` of `twitter.json` | 1.40 ms | 0.212 ms | 6.6× | 6.0× |
+| `dump()` of `canada.json` | 6.69 ms | 2.30 ms | 2.9× | 3.4× |
+| `dump(4)` of `citm_catalog.json` | 1.93 ms | 0.415 ms | 4.6× | 3.9× |
+| `to_cbor()` of `twitter.json` | 0.638 ms | 0.140 ms | 4.5× | 6.6× |
+| `from_cbor()` of `twitter.json` from memory | 3.05 ms | 0.865 ms | 3.5× | 3.3× |
+| `from_cbor()` of `twitter.json` from a `FILE*` | 9.84 ms | 1.06 ms | 9.3× | 8.6× |
+| `diff()` of `canada.json` with every eighth scalar changed | 38.1 ms | 3.74 ms | 10.2× | 11.3× |
+| iterating over every value of `canada.json` | 0.871 ms | 0.427 ms | 2.0× | 1.91× |
+| copying `citm_catalog.json` and destroying the copy | 1.62 ms | 1.47 ms | 1.10× | 1.09× |
+| `==` of `citm_catalog.json` and a copy | 0.258 ms | 0.255 ms | 1.01× | 0.90× |
Time per call with 3.12.0 and 3.13.0, Google Benchmark suite on an Apple M1 Max,
median of 12 runs; the speedup is the old time divided by the new one. The Intel column is the speedup on the Intel
MacBook Pro of [Appendix G](#g-how-we-measured). The parse rows do not include destroying the result (the suite pauses
the timer for that).
-??? info "All 182 benchmarks of the suite"
+??? info "All 184 benchmarks of the suite"
| benchmark | 3.12.0 | 3.13.0 | speedup | Intel |
| --- | --: | --: | --: | --: |
- | `Accept/canada` | 12.8 ms | 1.34 ms | 9.51× | 13× |
- | `Accept/citm_catalog` | 6.48 ms | 474 µs | 13.7× | 8.45× |
- | `Accept/floats` | 114 ms | 17.2 ms | 6.63× | 12.2× |
- | `Accept/jeopardy` | 218 ms | 27.9 ms | 7.82× | 6.64× |
- | `Accept/signed_ints` | 116 ms | 23.4 ms | 4.96× | 4.99× |
- | `Accept/small_signed_ints` | 56.5 ms | 13.2 ms | 4.29× | 3.90× |
- | `Accept/twitter` | 2.49 ms | 234 µs | 10.6× | 6.89× |
- | `Accept/unsigned_ints` | 115 ms | 22.8 ms | 5.03× | 4.95× |
- | `BinaryToCbor/1024` | 315 ns | 108 ns | 2.92× | 3.67× |
- | `BinaryToCbor/128` | 266 ns | 114 ns | 2.33× | 2.27× |
- | `BinaryToCbor/16384` | 950 ns | 418 ns | 2.27× | 3.46× |
- | `BinaryToCbor/16` | 246 ns | 49.9 ns | 4.93× | 6.33× |
- | `BinaryToCbor/2048` | 340 ns | 127 ns | 2.68× | 3.74× |
- | `BinaryToCbor/256` | 280 ns | 91.8 ns | 3.05× | 3.33× |
- | `BinaryToCbor/32768` | 1.58 µs | 838 ns | 1.88× | 2.11× |
- | `BinaryToCbor/32` | 262 ns | 50.3 ns | 5.21× | 6.24× |
- | `BinaryToCbor/4096` | 432 ns | 174 ns | 2.48× | 3.48× |
- | `BinaryToCbor/512` | 297 ns | 102 ns | 2.91× | 3.02× |
- | `BinaryToCbor/64` | 259 ns | 84.3 ns | 3.08× | 3.78× |
- | `BinaryToCbor/8192` | 527 ns | 254 ns | 2.08× | 3.30× |
- | `BinaryToCbor/8` | 251 ns | 49.9 ns | 5.02× | 6.18× |
- | `Copy/canada` | 3.69 ms | 2.9 ms | 1.27× | 1.17× |
- | `Copy/citm_catalog` | 1.65 ms | 1.49 ms | 1.11× | 1.12× |
- | `Copy/twitter` | 811 µs | 729 µs | 1.11× | 1.14× |
- | `CopyAssign/canada` | 3.74 ms | 2.94 ms | 1.27× | 1.19× |
- | `CopyAssign/citm_catalog` | 1.65 ms | 1.54 ms | 1.08× | 1.12× |
- | `CopyAssign/twitter` | 818 µs | 752 µs | 1.09× | 1.07× |
- | `CopyOnly/canada` | 1.54 ms | 1.52 ms | 1.01× | 1.00× |
- | `CopyOnly/citm_catalog` | 755 µs | 795 µs | 0.95× | 0.93× |
- | `CopyOnly/twitter` | 407 µs | 410 µs | 0.99× | 1.02× |
- | `CopyRing/canada` | 3.75 ms | 2.93 ms | 1.28× | 1.20× |
- | `CopyRing/citm_catalog` | 1.75 ms | 1.55 ms | 1.13× | 1.20× |
- | `CopyRing/twitter` | 876 µs | 784 µs | 1.12× | 1.15× |
- | `DestroyOnly/canada` | 2.16 ms | 1.38 ms | 1.56× | 1.32× |
- | `DestroyOnly/citm_catalog` | 896 µs | 682 µs | 1.31× | 1.20× |
- | `DestroyOnly/twitter` | 406 µs | 327 µs | 1.24× | 1.15× |
- | `Diff/canada` | 39.2 ms | 3.75 ms | 10.4× | 11.2× |
- | `Diff/citm_catalog` | 6.92 ms | 1.09 ms | 6.33× | 7.78× |
- | `Diff/twitter` | 4.93 ms | 640 µs | 7.71× | 8.79× |
- | `Dump/canada / -` | 6.71 ms | 2.31 ms | 2.90× | 3.34× |
- | `Dump/canada / 4` | 8.82 ms | 3.03 ms | 2.91× | 2.82× |
- | `Dump/citm_catalog / -` | 1.39 ms | 296 µs | 4.71× | 3.93× |
- | `Dump/citm_catalog / 4` | 1.95 ms | 422 µs | 4.62× | 4.09× |
- | `Dump/floats / -` | 63.5 ms | 23.8 ms | 2.67× | 2.50× |
- | `Dump/floats / 4` | 72 ms | 24.7 ms | 2.92× | 2.71× |
- | `Dump/jeopardy / -` | 202 ms | 30.6 ms | 6.59× | 3.75× |
- | `Dump/jeopardy / 4` | 220 ms | 34.4 ms | 6.42× | 2.61× |
- | `Dump/signed_ints / -` | 23.7 ms | 10.7 ms | 2.21× | 1.44× |
- | `Dump/signed_ints / 4` | 32 ms | 11.4 ms | 2.82× | 2.01× |
- | `Dump/small_signed_ints / -` | 17.9 ms | 7.93 ms | 2.25× | 1.81× |
- | `Dump/small_signed_ints / 4` | 25.1 ms | 8.81 ms | 2.84× | 2.21× |
- | `Dump/twitter / -` | 1.41 ms | 214 µs | 6.60× | 5.75× |
- | `Dump/twitter / 4` | 1.59 ms | 249 µs | 6.38× | 5.18× |
- | `Dump/unsigned_ints / -` | 23.6 ms | 8.07 ms | 2.92× | 1.58× |
- | `Dump/unsigned_ints / 4` | 31.7 ms | 8.51 ms | 3.73× | 2.30× |
- | `Equal/canada` | 463 µs | 336 µs | 1.38× | 1.38× |
- | `Equal/citm_catalog` | 264 µs | 261 µs | 1.01× | 0.95× |
- | `Equal/twitter` | 139 µs | 129 µs | 1.08× | 1.02× |
- | `Flatten/canada` | 28.7 ms | 11.2 ms | 2.56× | 2.68× |
- | `Flatten/citm_catalog` | 6.44 ms | 3.01 ms | 2.14× | 2.45× |
- | `Flatten/twitter` | 3.53 ms | 2.05 ms | 1.72× | 2.19× |
- | `FlattenOrdered/citm_catalog` | 256 ms | 1.41 ms | 182× | 185× |
- | `FlattenOrdered/twitter` | 50 ms | 864 µs | 57.9× | 46.1× |
- | `FromBinaryBuffer/bjdata / canada` | 8.15 ms | 4.17 ms | 1.95× | 2.02× |
- | `FromBinaryBuffer/bjdata / twitter` | 3.18 ms | 893 µs | 3.56× | 2.87× |
- | `FromBinaryBuffer/bjdata_optimized / canada` | 8.74 ms | 2.42 ms | 3.61× | 3.51× |
- | `FromBinaryBuffer/bjdata_optimized / twitter` | 3.16 ms | 885 µs | 3.57× | 2.86× |
- | `FromBinaryBuffer/bson / canada` | 9.33 ms | 4.27 ms | 2.18× | 2.20× |
- | `FromBinaryBuffer/bson / citm_catalog` | 3.92 ms | 1.61 ms | 2.43× | 2.59× |
- | `FromBinaryBuffer/bson / twitter` | 3.18 ms | 910 µs | 3.49× | 3.08× |
- | `FromBinaryBuffer/cbor / canada` | 8.39 ms | 2.08 ms | 4.03× | 3.86× |
- | `FromBinaryBuffer/cbor / citm_catalog` | 3.71 ms | 1.32 ms | 2.81× | 2.81× |
- | `FromBinaryBuffer/cbor / floats` | 29.2 ms | 5.48 ms | 5.32× | 3.64× |
- | `FromBinaryBuffer/cbor / jeopardy` | 353 ms | 101 ms | 3.50× | 3.43× |
- | `FromBinaryBuffer/cbor / signed_ints` | 36 ms | 9.78 ms | 3.68× | 2.37× |
- | `FromBinaryBuffer/cbor / twitter` | 3.09 ms | 879 µs | 3.52× | 2.83× |
- | `FromBinaryBuffer/msgpack / canada` | 8.26 ms | 2.1 ms | 3.94× | 3.92× |
- | `FromBinaryBuffer/msgpack / citm_catalog` | 3.72 ms | 1.29 ms | 2.89× | 2.94× |
- | `FromBinaryBuffer/msgpack / jeopardy` | 357 ms | 96.9 ms | 3.68× | 3.51× |
- | `FromBinaryBuffer/msgpack / twitter` | 3.06 ms | 850 µs | 3.60× | 3.02× |
- | `FromBinaryBuffer/ubjson / canada` | 8.13 ms | 4.14 ms | 1.96× | 2.13× |
- | `FromBinaryBuffer/ubjson / citm_catalog` | 3.82 ms | 1.66 ms | 2.31× | 2.44× |
- | `FromBinaryBuffer/ubjson / jeopardy` | 366 ms | 101 ms | 3.61× | 3.40× |
- | `FromBinaryBuffer/ubjson / twitter` | 3.15 ms | 896 µs | 3.52× | 2.90× |
- | `FromBinaryBuffer/ubjson_optimized / canada` | 8.51 ms | 2.39 ms | 3.56× | 3.67× |
- | `FromBinaryBuffer/ubjson_optimized / twitter` | 3.12 ms | 882 µs | 3.54× | 2.88× |
- | `FromBinaryFile/bjdata / twitter` | 10.4 ms | 1.45 ms | 7.18× | 5.89× |
- | `FromBinaryFile/bson / twitter` | 10.3 ms | 1.24 ms | 8.33× | 6.21× |
- | `FromBinaryFile/cbor / canada` | 14.3 ms | 2.41 ms | 5.96× | 3.68× |
- | `FromBinaryFile/cbor / twitter` | 9.92 ms | 1.07 ms | 9.23× | 6.46× |
- | `FromBinaryFile/ubjson / canada` | 13.6 ms | 6.23 ms | 2.17× | 2.50× |
- | `FromBinaryFile/ubjson / twitter` | 10.5 ms | 1.46 ms | 7.20× | 5.90× |
- | `FromBinaryShape/containers / bjdata` | 14.3 ms | 7.24 ms | 1.98× | 2.05× |
- | `FromBinaryShape/containers / bson` | 17.4 ms | 7.98 ms | 2.18× | 2.20× |
- | `FromBinaryShape/containers / cbor` | 13.9 ms | 3.93 ms | 3.54× | 3.49× |
- | `FromBinaryShape/containers / msgpack` | 13.8 ms | 3.88 ms | 3.55× | 3.52× |
- | `FromBinaryShape/containers / ubjson_optimized` | 15 ms | 4.49 ms | 3.34× | 3.34× |
- | `FromBinaryShape/containers / ubjson` | 14.4 ms | 7.27 ms | 1.98× | 2.03× |
- | `FromBinaryShape/nested / bjdata` | 96.4 µs | 38.2 µs | 2.52× | 2.50× |
- | `FromBinaryShape/nested / bson` | 103 µs | 42.5 µs | 2.41× | 2.42× |
- | `FromBinaryShape/nested / cbor` | 93.8 µs | 35.4 µs | 2.65× | 2.57× |
- | `FromBinaryShape/nested / msgpack` | 92 µs | 34.9 µs | 2.64× | 2.60× |
- | `FromBinaryShape/nested / ubjson` | 96.5 µs | 37.9 µs | 2.54× | 2.50× |
- | `FromBinaryShape/scalars / bjdata` | 24.8 ms | 11.5 ms | 2.16× | 2.22× |
- | `FromBinaryShape/scalars / cbor` | 25.7 ms | 5.69 ms | 4.51× | 3.56× |
- | `FromBinaryShape/scalars / msgpack` | 24.4 ms | 5.57 ms | 4.39× | 3.69× |
- | `FromBinaryShape/scalars / ubjson` | 24.9 ms | 11.6 ms | 2.15× | 2.03× |
- | `FromCborChunkedString/10000 chunks` | 90.9 µs | 61.5 µs | 1.48× | 1.09× |
- | `FromMsgpack/canada` | 14.4 ms | 2.4 ms | 5.97× | 3.63× |
- | `FromMsgpack/citm_catalog` | 9.04 ms | 1.67 ms | 5.42× | 4.60× |
- | `FromMsgpack/floats` | 59.8 ms | 28.2 ms | 2.12× | 2.89× |
- | `FromMsgpack/jeopardy` | 1,140 ms | 112 ms | 10.2× | 6.80× |
- | `FromMsgpack/signed_ints` | 63.1 ms | 32.7 ms | 1.93× | 2.44× |
- | `FromMsgpack/small_signed_ints` | 63.4 ms | 35.3 ms | 1.80× | 2.33× |
- | `FromMsgpack/twitter` | 9.99 ms | 1.01 ms | 9.87× | 6.76× |
- | `FromMsgpack/unsigned_ints` | 56.1 ms | 28.2 ms | 1.99× | 2.77× |
- | `GetArray>` | 2.24 µs | 641 ns | 3.50× | 5.38× |
- | `GetArray>` | 8.16 µs | 1.17 µs | 6.96× | 4.75× |
- | `GetArray>` | 58.8 µs | 41.6 µs | 1.42× | 1.30× |
- | `GetArray>` | 6.73 µs | 671 ns | 10.0× | 4.10× |
- | `GetMap/citm_catalog` | 3.44 ms | 2.44 ms | 1.41× | 1.48× |
- | `GetVectorDouble/floats` | 6.7 ms | 651 µs | 10.3× | 2.98× |
- | `GetVectorInt/signed_ints` | 8.07 ms | 3.41 ms | 2.37× | 2.02× |
- | `Iterate/canada` | 874 µs | 445 µs | 1.96× | 2.02× |
- | `Iterate/citm_catalog` | 302 µs | 158 µs | 1.91× | 1.53× |
- | `Iterate/twitter` | 87.3 µs | 58.9 µs | 1.48× | 1.20× |
- | `JsonPointerAt/citm_catalog` | 1.85 ms | 1.16 ms | 1.60× | 1.47× |
- | `JsonPointerAt/twitter` | 791 µs | 600 µs | 1.32× | 1.14× |
- | `JsonPointerContains/citm_catalog` | 2.74 ms | 1.25 ms | 2.18× | 2.51× |
- | `JsonPointerContains/twitter` | 1.32 ms | 620 µs | 2.13× | 2.16× |
- | `JsonPointerParse/citm_catalog` | 5.73 ms | 2.21 ms | 2.59× | 3.74× |
- | `JsonPointerParse/twitter` | 2.47 ms | 1.01 ms | 2.45× | 3.18× |
- | `JsonPointerToString/citm_catalog` | 6.65 ms | 1.9 ms | 3.51× | 4.61× |
- | `JsonPointerToString/twitter` | 2.14 ms | 812 µs | 2.63× | 2.66× |
- | `ParseFILE/canada` | 52.9 ms | 6.02 ms | 8.79× | 5.46× |
- | `ParseFILE/citm_catalog` | 35 ms | 2.34 ms | 14.9× | 5.73× |
- | `ParseFILE/twitter` | 13.8 ms | 1.35 ms | 10.2× | 4.24× |
- | `ParseFile/canada` | 17.7 ms | 6.23 ms | 2.84× | 4.67× |
- | `ParseFile/citm_catalog` | 7.86 ms | 2.47 ms | 3.18× | 2.98× |
- | `ParseFile/floats` | 129 ms | 48.4 ms | 2.67× | 5.68× |
- | `ParseFile/jeopardy` | 330 ms | 156 ms | 2.12× | 2.23× |
- | `ParseFile/signed_ints` | 128 ms | 46.6 ms | 2.74× | 3.41× |
- | `ParseFile/small_signed_ints` | 64.5 ms | 33.4 ms | 1.93× | 2.57× |
- | `ParseFile/twitter` | 3.4 ms | 1.38 ms | 2.46× | 2.33× |
- | `ParseFile/unsigned_ints` | 123 ms | 47.3 ms | 2.61× | 3.52× |
- | `ParseIndented/canada / 4` | 34.2 ms | 4.61 ms | 7.41× | 8.02× |
- | `ParseIndented/citm_catalog / 4` | 7.45 ms | 1.46 ms | 5.11× | 3.49× |
- | `ParseIndented/jeopardy / 4` | 339 ms | 114 ms | 2.96× | 2.46× |
- | `ParseIndented/twitter / 4` | 3.61 ms | 975 µs | 3.70× | 2.60× |
- | `ParseStreamValues/ndjson` | 7.08 ms | 3.72 ms | 1.91× | 2.06× |
- | `ParseStreamValues/numbers` | 1.93 ms | 388 µs | 4.97× | 6.06× |
- | `ParseString/canada` | 15.2 ms | 3.73 ms | 4.08× | 6.13× |
- | `ParseString/citm_catalog` | 7.4 ms | 1.45 ms | 5.11× | 3.46× |
- | `ParseString/floats` | 120 ms | 25 ms | 4.80× | 8.68× |
- | `ParseString/jeopardy` | 303 ms | 113 ms | 2.68× | 2.32× |
- | `ParseString/signed_ints` | 121 ms | 28.7 ms | 4.22× | 4.29× |
- | `ParseString/small_signed_ints` | 60.8 ms | 17.7 ms | 3.43× | 3.38× |
- | `ParseString/twitter` | 3.21 ms | 921 µs | 3.49× | 2.60× |
- | `ParseString/unsigned_ints` | 120 ms | 28.5 ms | 4.21× | 4.23× |
- | `ParseStringOrdered/canada` | 15.3 ms | 3.78 ms | 4.04× | 6.21× |
- | `ParseStringOrdered/citm_catalog` | 11 ms | 1.34 ms | 8.18× | 6.59× |
- | `ParseStringOrdered/jeopardy` | 360 ms | 98.1 ms | 3.67× | 3.38× |
- | `ParseStringOrdered/twitter` | 4.41 ms | 804 µs | 5.49× | 4.93× |
- | `Patch/canada` | 10.1 ms | 3.41 ms | 2.97× | 2.46× |
- | `Patch/citm_catalog` | 2.54 ms | 1.65 ms | 1.54× | 1.38× |
- | `Patch/twitter` | 1.49 ms | 870 µs | 1.72× | 1.45× |
- | `SaxParse/canada` | 12.9 ms | 2.5 ms | 5.15× | 8.84× |
- | `SaxParse/citm_catalog` | 6.44 ms | 655 µs | 9.82× | 6.85× |
- | `SaxParse/twitter` | 2.49 ms | 334 µs | 7.45× | 5.91× |
- | `ToCbor/canada` | 1.39 ms | 555 µs | 2.51× | 2.27× |
- | `ToCbor/citm_catalog` | 1.03 ms | 260 µs | 3.97× | 5.60× |
- | `ToCbor/floats` | 8.94 ms | 1.85 ms | 4.84× | 1.94× |
- | `ToCbor/jeopardy` | 71.5 ms | 21.1 ms | 3.39× | 2.87× |
- | `ToCbor/signed_ints` | 11.4 ms | 2.74 ms | 4.15× | 1.83× |
- | `ToCbor/small_signed_ints` | 10.3 ms | 2.38 ms | 4.33× | 2.78× |
- | `ToCbor/twitter` | 637 µs | 144 µs | 4.41× | 6.67× |
- | `ToCbor/unsigned_ints` | 8.05 ms | 2.74 ms | 2.94× | 1.48× |
- | `ToJsonStrings/copy` | 5.86 ms | 5.6 ms | 1.05× | 1.05× |
- | `ToJsonStrings/move` | 5.92 ms | 3.05 ms | 1.94× | 1.78× |
- | `Unflatten/canada` | 41.8 ms | 10.8 ms | 3.86× | 4.32× |
- | `Unflatten/citm_catalog` | 9.8 ms | 3.54 ms | 2.77× | 3.32× |
- | `Unflatten/twitter` | 4.57 ms | 2.17 ms | 2.11× | 2.42× |
+ | `Accept/canada` | 12.7 ms | 1.32 ms | 9.59× | 27.3× |
+ | `Accept/citm_catalog` | 6.38 ms | 474 µs | 13.5× | 14.6× |
+ | `Accept/floats` | 113 ms | 17.2 ms | 6.60× | 17.6× |
+ | `Accept/jeopardy` | 217 ms | 27.7 ms | 7.81× | 11.7× |
+ | `Accept/signed_ints` | 115 ms | 23.3 ms | 4.94× | 6.08× |
+ | `Accept/small_signed_ints` | 56.3 ms | 13.2 ms | 4.25× | 5.86× |
+ | `Accept/twitter` | 2.47 ms | 233 µs | 10.6× | 15.4× |
+ | `Accept/unsigned_ints` | 114 ms | 22.9 ms | 4.99× | 6.31× |
+ | `BinaryToCbor/1024` | 310 ns | 104 ns | 3.00× | 3.80× |
+ | `BinaryToCbor/128` | 255 ns | 114 ns | 2.24× | 2.23× |
+ | `BinaryToCbor/16384` | 982 ns | 411 ns | 2.39× | 3.41× |
+ | `BinaryToCbor/16` | 245 ns | 48.3 ns | 5.08× | 6.14× |
+ | `BinaryToCbor/2048` | 330 ns | 122 ns | 2.70× | 3.64× |
+ | `BinaryToCbor/256` | 276 ns | 89.5 ns | 3.08× | 3.19× |
+ | `BinaryToCbor/32768` | 1.58 µs | 801 ns | 1.97× | 1.89× |
+ | `BinaryToCbor/32` | 255 ns | 49.7 ns | 5.13× | 6.07× |
+ | `BinaryToCbor/4096` | 408 ns | 169 ns | 2.41× | 3.51× |
+ | `BinaryToCbor/512` | 293 ns | 98.3 ns | 2.98× | 3.00× |
+ | `BinaryToCbor/64` | 258 ns | 83.4 ns | 3.09× | 3.73× |
+ | `BinaryToCbor/8192` | 514 ns | 248 ns | 2.07× | 3.31× |
+ | `BinaryToCbor/8` | 247 ns | 48.7 ns | 5.07× | 6.07× |
+ | `Copy/canada` | 3.67 ms | 2.92 ms | 1.26× | 1.19× |
+ | `Copy/citm_catalog` | 1.62 ms | 1.47 ms | 1.10× | 1.09× |
+ | `Copy/twitter` | 800 µs | 726 µs | 1.10× | 1.08× |
+ | `CopyAssign/canada` | 3.73 ms | 2.95 ms | 1.26× | 1.18× |
+ | `CopyAssign/citm_catalog` | 1.66 ms | 1.50 ms | 1.10× | 1.14× |
+ | `CopyAssign/twitter` | 810 µs | 768 µs | 1.05× | 1.06× |
+ | `CopyOnly/canada` | 1.53 ms | 1.53 ms | 1.00× | 0.985× |
+ | `CopyOnly/citm_catalog` | 745 µs | 795 µs | 0.938× | 0.951× |
+ | `CopyOnly/twitter` | 398 µs | 411 µs | 0.969× | 0.996× |
+ | `CopyRing/canada` | 3.73 ms | 2.94 ms | 1.27× | 1.16× |
+ | `CopyRing/citm_catalog` | 1.71 ms | 1.55 ms | 1.10× | 1.20× |
+ | `CopyRing/twitter` | 859 µs | 799 µs | 1.07× | 1.11× |
+ | `DestroyOnly/canada` | 2.14 ms | 1.38 ms | 1.55× | 1.36× |
+ | `DestroyOnly/citm_catalog` | 879 µs | 679 µs | 1.29× | 1.20× |
+ | `DestroyOnly/twitter` | 401 µs | 326 µs | 1.23× | 1.15× |
+ | `Diff/canada` | 38.1 ms | 3.74 ms | 10.2× | 11.3× |
+ | `Diff/citm_catalog` | 6.81 ms | 1.09 ms | 6.27× | 7.92× |
+ | `Diff/twitter` | 4.86 ms | 640 µs | 7.59× | 8.66× |
+ | `Dump/canada / -` | 6.69 ms | 2.30 ms | 2.91× | 3.36× |
+ | `Dump/canada / 4` | 8.86 ms | 3.03 ms | 2.92× | 2.99× |
+ | `Dump/citm_catalog / -` | 1.38 ms | 292 µs | 4.74× | 4.06× |
+ | `Dump/citm_catalog / 4` | 1.93 ms | 415 µs | 4.64× | 3.88× |
+ | `Dump/floats / -` | 63.1 ms | 23.6 ms | 2.67× | 2.60× |
+ | `Dump/floats / 4` | 71.0 ms | 24.6 ms | 2.89× | 2.77× |
+ | `Dump/jeopardy / -` | 201 ms | 31.2 ms | 6.44× | 3.68× |
+ | `Dump/jeopardy / 4` | 219 ms | 34.5 ms | 6.35× | 2.59× |
+ | `Dump/signed_ints / -` | 23.6 ms | 10.7 ms | 2.21× | 1.46× |
+ | `Dump/signed_ints / 4` | 31.8 ms | 11.2 ms | 2.83× | 2.00× |
+ | `Dump/small_signed_ints / -` | 17.8 ms | 7.93 ms | 2.25× | 1.78× |
+ | `Dump/small_signed_ints / 4` | 24.9 ms | 8.73 ms | 2.85× | 2.10× |
+ | `Dump/twitter / -` | 1.40 ms | 212 µs | 6.58× | 5.96× |
+ | `Dump/twitter / 4` | 1.58 ms | 249 µs | 6.36× | 5.47× |
+ | `Dump/unsigned_ints / -` | 23.5 ms | 8.05 ms | 2.91× | 1.58× |
+ | `Dump/unsigned_ints / 4` | 31.7 ms | 8.42 ms | 3.76× | 2.17× |
+ | `Equal/canada` | 456 µs | 333 µs | 1.37× | 1.23× |
+ | `Equal/citm_catalog` | 258 µs | 255 µs | 1.01× | 0.896× |
+ | `Equal/twitter` | 137 µs | 128 µs | 1.07× | 1.03× |
+ | `Flatten/canada` | 28.5 ms | 11.3 ms | 2.52× | 2.61× |
+ | `Flatten/citm_catalog` | 6.40 ms | 2.99 ms | 2.14× | 2.45× |
+ | `Flatten/twitter` | 3.48 ms | 2.04 ms | 1.70× | 2.18× |
+ | `FlattenOrdered/citm_catalog` | 255 ms | 1.40 ms | 182× | 211× |
+ | `FlattenOrdered/twitter` | 49.6 ms | 863 µs | 57.6× | 55.4× |
+ | `FromBinaryBuffer/bjdata / canada` | 8.10 ms | 4.08 ms | 1.99× | 2.06× |
+ | `FromBinaryBuffer/bjdata / twitter` | 3.13 ms | 873 µs | 3.58× | 3.13× |
+ | `FromBinaryBuffer/bjdata_optimized / canada` | 8.58 ms | 2.41 ms | 3.56× | 3.51× |
+ | `FromBinaryBuffer/bjdata_optimized / twitter` | 3.13 ms | 866 µs | 3.61× | 3.16× |
+ | `FromBinaryBuffer/bson / canada` | 9.28 ms | 4.35 ms | 2.14× | 2.13× |
+ | `FromBinaryBuffer/bson / citm_catalog` | 3.87 ms | 1.59 ms | 2.44× | 2.64× |
+ | `FromBinaryBuffer/bson / twitter` | 3.08 ms | 892 µs | 3.45× | 3.24× |
+ | `FromBinaryBuffer/cbor / canada` | 8.26 ms | 2.10 ms | 3.93× | 3.87× |
+ | `FromBinaryBuffer/cbor / citm_catalog` | 3.69 ms | 1.34 ms | 2.76× | 3.03× |
+ | `FromBinaryBuffer/cbor / floats` | 28.9 ms | 5.39 ms | 5.37× | 3.66× |
+ | `FromBinaryBuffer/cbor / jeopardy` | 354 ms | 101 ms | 3.51× | 3.80× |
+ | `FromBinaryBuffer/cbor / signed_ints` | 35.6 ms | 9.76 ms | 3.64× | 2.53× |
+ | `FromBinaryBuffer/cbor / twitter` | 3.05 ms | 865 µs | 3.52× | 3.25× |
+ | `FromBinaryBuffer/msgpack / canada` | 8.24 ms | 2.10 ms | 3.93× | 3.92× |
+ | `FromBinaryBuffer/msgpack / citm_catalog` | 3.71 ms | 1.29 ms | 2.88× | 3.07× |
+ | `FromBinaryBuffer/msgpack / jeopardy` | 356 ms | 93.7 ms | 3.80× | 3.98× |
+ | `FromBinaryBuffer/msgpack / twitter` | 3.03 ms | 831 µs | 3.65× | 3.27× |
+ | `FromBinaryBuffer/ubjson / canada` | 8.10 ms | 4.14 ms | 1.96× | 2.12× |
+ | `FromBinaryBuffer/ubjson / citm_catalog` | 3.84 ms | 1.63 ms | 2.36× | 2.57× |
+ | `FromBinaryBuffer/ubjson / jeopardy` | 366 ms | 99.4 ms | 3.68× | 3.71× |
+ | `FromBinaryBuffer/ubjson / twitter` | 3.12 ms | 872 µs | 3.58× | 3.17× |
+ | `FromBinaryBuffer/ubjson_optimized / canada` | 8.45 ms | 2.38 ms | 3.55× | 3.53× |
+ | `FromBinaryBuffer/ubjson_optimized / twitter` | 3.10 ms | 860 µs | 3.61× | 3.16× |
+ | `FromBinaryFile/bjdata / twitter` | 10.4 ms | 1.46 ms | 7.12× | 7.22× |
+ | `FromBinaryFile/bson / twitter` | 10.2 ms | 1.23 ms | 8.30× | 8.17× |
+ | `FromBinaryFile/cbor / canada` | 14.2 ms | 2.42 ms | 5.89× | 5.71× |
+ | `FromBinaryFile/cbor / twitter` | 9.84 ms | 1.06 ms | 9.31× | 8.65× |
+ | `FromBinaryFile/ubjson / canada` | 13.5 ms | 6.35 ms | 2.13× | 2.50× |
+ | `FromBinaryFile/ubjson / twitter` | 10.4 ms | 1.44 ms | 7.20× | 7.26× |
+ | `FromBinaryShape/containers / bjdata` | 14.1 ms | 7.07 ms | 1.99× | 1.98× |
+ | `FromBinaryShape/containers / bson` | 16.6 ms | 7.72 ms | 2.15× | 2.14× |
+ | `FromBinaryShape/containers / cbor` | 13.8 ms | 3.95 ms | 3.49× | 3.56× |
+ | `FromBinaryShape/containers / msgpack` | 13.8 ms | 3.95 ms | 3.48× | 3.56× |
+ | `FromBinaryShape/containers / ubjson_optimized` | 14.7 ms | 4.44 ms | 3.32× | 3.23× |
+ | `FromBinaryShape/containers / ubjson` | 14.0 ms | 7.04 ms | 1.99× | 2.00× |
+ | `FromBinaryShape/nested / bjdata` | 95.6 µs | 37.9 µs | 2.52× | 2.56× |
+ | `FromBinaryShape/nested / bson` | 102 µs | 42.2 µs | 2.41× | 2.53× |
+ | `FromBinaryShape/nested / cbor` | 93.7 µs | 35.2 µs | 2.66× | 2.68× |
+ | `FromBinaryShape/nested / msgpack` | 92.2 µs | 34.8 µs | 2.65× | 2.65× |
+ | `FromBinaryShape/nested / ubjson` | 96.1 µs | 37.9 µs | 2.53× | 2.61× |
+ | `FromBinaryShape/scalars / bjdata` | 24.5 ms | 11.2 ms | 2.19× | 2.19× |
+ | `FromBinaryShape/scalars / cbor` | 25.6 ms | 5.56 ms | 4.60× | 3.72× |
+ | `FromBinaryShape/scalars / msgpack` | 24.3 ms | 5.38 ms | 4.52× | 3.59× |
+ | `FromBinaryShape/scalars / ubjson` | 24.6 ms | 11.1 ms | 2.21× | 2.01× |
+ | `FromBinaryShape/singles / msgpack` | 9.80 ms | 3.84 ms | 2.55× | 2.75× |
+ | `FromBinaryShape/singles / cbor` | 9.80 ms | 3.85 ms | 2.55× | 2.69× |
+ | `FromCborChunkedString/10000 chunks` | 90.1 µs | 61.2 µs | 1.47× | 1.45× |
+ | `FromMsgpack/canada` | 14.4 ms | 2.41 ms | 5.99× | 5.59× |
+ | `FromMsgpack/citm_catalog` | 8.92 ms | 1.65 ms | 5.40× | 5.81× |
+ | `FromMsgpack/floats` | 59.5 ms | 27.9 ms | 2.13× | 2.87× |
+ | `FromMsgpack/jeopardy` | 1.14 s | 112 ms | 10.2× | 10.4× |
+ | `FromMsgpack/signed_ints` | 62.3 ms | 32.7 ms | 1.91× | 2.46× |
+ | `FromMsgpack/small_signed_ints` | 62.9 ms | 33.7 ms | 1.86× | 2.42× |
+ | `FromMsgpack/twitter` | 9.92 ms | 1000 µs | 9.92× | 8.95× |
+ | `FromMsgpack/unsigned_ints` | 55.6 ms | 28.1 ms | 1.98× | 2.83× |
+ | `GetArray>` | 2.23 µs | 640 ns | 3.49× | 5.78× |
+ | `GetArray>` | 8.12 µs | 1.16 µs | 6.97× | 4.40× |
+ | `GetArray>` | 58.2 µs | 41.5 µs | 1.40× | 1.33× |
+ | `GetArray>` | 6.67 µs | 668 ns | 9.98× | 4.00× |
+ | `GetMap/citm_catalog` | 3.40 ms | 2.43 ms | 1.40× | 1.49× |
+ | `GetVectorDouble/floats` | 6.68 ms | 659 µs | 10.1× | 2.93× |
+ | `GetVectorInt/signed_ints` | 8.00 ms | 3.39 ms | 2.36× | 1.96× |
+ | `Iterate/canada` | 871 µs | 427 µs | 2.04× | 1.91× |
+ | `Iterate/citm_catalog` | 299 µs | 147 µs | 2.04× | 1.62× |
+ | `Iterate/twitter` | 87.8 µs | 57.1 µs | 1.54× | 1.33× |
+ | `JsonPointerAt/citm_catalog` | 1.84 ms | 1.15 ms | 1.60× | 1.45× |
+ | `JsonPointerAt/twitter` | 791 µs | 593 µs | 1.33× | 1.11× |
+ | `JsonPointerContains/citm_catalog` | 2.70 ms | 1.24 ms | 2.17× | 2.37× |
+ | `JsonPointerContains/twitter` | 1.29 ms | 610 µs | 2.12× | 1.97× |
+ | `JsonPointerParse/citm_catalog` | 5.70 ms | 2.22 ms | 2.57× | 3.64× |
+ | `JsonPointerParse/twitter` | 2.45 ms | 1.00 ms | 2.45× | 3.12× |
+ | `JsonPointerToString/citm_catalog` | 6.58 ms | 1.91 ms | 3.45× | 4.29× |
+ | `JsonPointerToString/twitter` | 2.14 ms | 812 µs | 2.63× | 2.64× |
+ | `ParseFILE/canada` | 52.3 ms | 5.95 ms | 8.80× | 8.91× |
+ | `ParseFILE/citm_catalog` | 34.8 ms | 2.34 ms | 14.9× | 10.3× |
+ | `ParseFILE/twitter` | 13.6 ms | 1.31 ms | 10.4× | 7.95× |
+ | `ParseFile/canada` | 17.4 ms | 6.24 ms | 2.80× | 4.76× |
+ | `ParseFile/citm_catalog` | 7.73 ms | 2.44 ms | 3.17× | 2.95× |
+ | `ParseFile/floats` | 128 ms | 48.2 ms | 2.66× | 5.72× |
+ | `ParseFile/jeopardy` | 330 ms | 158 ms | 2.09× | 2.18× |
+ | `ParseFile/signed_ints` | 126 ms | 46.0 ms | 2.74× | 3.23× |
+ | `ParseFile/small_signed_ints` | 63.7 ms | 33.2 ms | 1.92× | 2.56× |
+ | `ParseFile/twitter` | 3.35 ms | 1.36 ms | 2.47× | 2.35× |
+ | `ParseFile/unsigned_ints` | 122 ms | 47.4 ms | 2.57× | 3.07× |
+ | `ParseIndented/canada / 4` | 33.7 ms | 4.55 ms | 7.40× | 8.52× |
+ | `ParseIndented/citm_catalog / 4` | 7.26 ms | 1.46 ms | 4.96× | 4.06× |
+ | `ParseIndented/jeopardy / 4` | 337 ms | 113 ms | 2.97× | 2.79× |
+ | `ParseIndented/twitter / 4` | 3.59 ms | 956 µs | 3.76× | 2.82× |
+ | `ParseStreamValues/ndjson` | 7.13 ms | 3.75 ms | 1.90× | 2.00× |
+ | `ParseStreamValues/numbers` | 1.92 ms | 385 µs | 4.99× | 5.90× |
+ | `ParseString/canada` | 15.1 ms | 3.73 ms | 4.05× | 7.05× |
+ | `ParseString/citm_catalog` | 7.31 ms | 1.45 ms | 5.05× | 4.04× |
+ | `ParseString/floats` | 119 ms | 24.5 ms | 4.85× | 9.44× |
+ | `ParseString/jeopardy` | 304 ms | 112 ms | 2.72× | 2.73× |
+ | `ParseString/signed_ints` | 120 ms | 29.0 ms | 4.15× | 4.36× |
+ | `ParseString/small_signed_ints` | 60.7 ms | 17.7 ms | 3.43× | 3.64× |
+ | `ParseString/twitter` | 3.19 ms | 902 µs | 3.53× | 2.92× |
+ | `ParseString/unsigned_ints` | 119 ms | 28.4 ms | 4.18× | 4.34× |
+ | `ParseStringOrdered/canada` | 15.0 ms | 3.77 ms | 3.99× | 7.20× |
+ | `ParseStringOrdered/citm_catalog` | 10.9 ms | 1.34 ms | 8.11× | 8.20× |
+ | `ParseStringOrdered/jeopardy` | 360 ms | 98.0 ms | 3.68× | 3.82× |
+ | `ParseStringOrdered/twitter` | 4.36 ms | 792 µs | 5.50× | 6.07× |
+ | `Patch/canada` | 10.0 ms | 3.40 ms | 2.94× | 2.42× |
+ | `Patch/citm_catalog` | 2.55 ms | 1.64 ms | 1.56× | 1.41× |
+ | `Patch/twitter` | 1.47 ms | 870 µs | 1.69× | 1.47× |
+ | `SaxParse/canada` | 12.8 ms | 2.52 ms | 5.08× | 11.6× |
+ | `SaxParse/citm_catalog` | 6.40 ms | 652 µs | 9.83× | 9.37× |
+ | `SaxParse/twitter` | 2.48 ms | 333 µs | 7.44× | 8.16× |
+ | `ToCbor/canada` | 1.37 ms | 559 µs | 2.45× | 2.18× |
+ | `ToCbor/citm_catalog` | 1.03 ms | 253 µs | 4.06× | 5.67× |
+ | `ToCbor/floats` | 8.90 ms | 1.84 ms | 4.83× | 2.32× |
+ | `ToCbor/jeopardy` | 71.6 ms | 20.5 ms | 3.49× | 2.93× |
+ | `ToCbor/signed_ints` | 11.3 ms | 2.73 ms | 4.15× | 2.13× |
+ | `ToCbor/small_signed_ints` | 10.2 ms | 2.38 ms | 4.30× | 3.00× |
+ | `ToCbor/twitter` | 638 µs | 140 µs | 4.54× | 6.63× |
+ | `ToCbor/unsigned_ints` | 8.02 ms | 2.74 ms | 2.93× | 1.65× |
+ | `ToJsonStrings/copy` | 5.86 ms | 5.59 ms | 1.05× | 1.07× |
+ | `ToJsonStrings/move` | 5.84 ms | 3.06 ms | 1.91× | 1.86× |
+ | `Unflatten/canada` | 41.2 ms | 11.0 ms | 3.73× | 4.29× |
+ | `Unflatten/citm_catalog` | 9.79 ms | 3.61 ms | 2.71× | 3.28× |
+ | `Unflatten/twitter` | 4.64 ms | 2.19 ms | 2.12× | 2.34× |
### C. The timeline
@@ -1958,7 +1982,7 @@ not shown in the timeline section. More is better; the badges are theme numbers.
The parse panels include destroying the result: the benchmark returns `json::parse(text).size()`, so the changes to the
destructor ([#5762][5762], [#5835][5835]) show up there too, as steps of up to 6% in either direction. When `accept()`
-of `twitter.json` got 2.5% slower over the last 20 commits, we timed the two ends against each other in one binary with
+of `twitter.json` got 2.5% slower over the 20 commits before [#6031][6031], we timed the two ends against each other in one binary with
six code layouts: they were equal within 0.2%.
| workload | theme | pull request | change | step |
@@ -1969,21 +1993,21 @@ six code layouts: they were equal within 0.2%.
| | 4 | [#5809][5809] | positions derived only on error | −12% |
| | 2 | [#5810][5810] | indentation skipped eight bytes at a time | −12% |
| | 4 | [#5882][5882] | arrays allocated once, at their final size | −6% |
-| | 1 | [#6031][6031] | one loop for parser and lexer on contiguous input | −12% |
+| | 1 | [#6031][6031] | one loop for parser and lexer on contiguous input | −11% |
| `parse()` `canada.json` | 4 | [#5234][5234] | the token buffer is filled only for error messages | −10% |
| | 1 | [#5283][5283] | fast paths for contiguous input | −24% |
| | 3 | [#5617][5617] | Eisel-Lemire instead of `strtod` | −9% |
| | 3 | [#5738][5738] | own float parser, string scan, `\u` table | −14% |
| | 3 | [#5851][5851] | digits accumulated while validating, eight at a time | −12% |
| | 4 | [#5882][5882] | arrays allocated once, at their final size | −15% |
-| | 1 | [#6031][6031] | one loop for parser and lexer on contiguous input | −16% |
+| | 1 | [#6031][6031] | one loop for parser and lexer on contiguous input | −15% |
| `accept()` `twitter.json` | 4 | [#5234][5234] | the token buffer is filled only for error messages | −18% |
| | 1 | [#5283][5283] | fast paths for contiguous input | −53% |
| | 4 | [#5592][5592] | check for the expected `:` or `,` before the lexer's token switch | −11% |
| | 4 | [#5809][5809] | positions derived only on error | −23% |
| | 2 | [#5810][5810] | indentation skipped eight bytes at a time | −9% |
| | 2 | [#5853][5853] | strings scanned 16 bytes at a time with SSE2 or NEON | −11% |
-| | 1 | [#6031][6031] | one loop for parser and lexer on contiguous input | −51% |
+| | 1 | [#6031][6031] | one loop for parser and lexer on contiguous input | −52% |
| `parse()` `twitter.json`, `std::ifstream` | 1 | [#5828][5828] | scanning the stream's get area in bulk | −48% |
| | 1 | [#5884][5884] | inline get-area path, binary reads | −5% |
| `dump()` `twitter.json` | 6 | [#5285][5285] | a write buffer and bulk copies of strings | −70% |
@@ -2002,25 +2026,25 @@ six code layouts: they were equal within 0.2%.
| | 6 | [#5885][5885] | runs of numbers encoded in a loop | −32% |
The labeled steps of the timeline: the change in time at the first commit of each
-pull request, against the commit before it; for [#6031][6031], which was not merged yet, the step to 3.13.0.
+pull request, against the commit before it.
[#5592][5592] is by [@mvanslobbe](https://github.com/mvanslobbe).
### D. Algorithmic fixes
| operation | 3.12.0 | 3.13.0 | speedup | cause | PR |
| --- | --: | --: | --: | --- | --- |
-| `diff()` of an array of 64,000 numbers against an empty array | 4,237 ms | 10.8 ms | 394× | each `remove` was inserted at the front of the patch | [#5461][5461] |
-| `diff()` of an array of 20,000 objects against every second one of them | 122 ms | 4.13 ms | 29× | the same | [#5461][5461] |
-| `parse()` with a callback that rejects half of 32,000 objects | 1,398 ms | 12.1 ms | 116× | each rejected value was searched for from the start of its parent | [#5457][5457] |
-| `<` on two equal values nested 24 levels deep (C++11 to C++17) | 64.4 ms | 0.002 ms | exponential | `std::vector`'s `<` asks `a < b` and `b < a`, and both recurse | [#5390][5390] |
-| `<` on `citm_catalog.json` and a copy, 10× (C++11 to C++17) | 284 ms | 3.94 ms | 72× | the same | [#5390][5390] |
-| `flatten()` of `citm_catalog.json` as `ordered_json` | 271 ms | 1.45 ms | 187× | every new key was looked up linearly | [#5834][5834] |
-| `to_bson()` of a value nested 200 levels deep, 100× | 20.3 ms | 0.352 ms | 58× | each document's size was computed by walking everything below it again | [#5553][5553], [#5979][5979] |
-| 100,000 × `push_back()` on an `ordered_json` with [`JSON_DIAGNOSTICS`](../../api/macros/json_diagnostics.md) | 1,589 ms | 5.32 ms | 299× | every insert re-pointed the parent pointers of all elements | [#5832][5832] |
-| 10,000 × `at(i)` on an `ordered_json` array with `JSON_DIAGNOSTICS` | 45.9 ms | 0.088 ms | 522× | the same | [#5832][5832] |
+| `diff()` of an array of 64,000 numbers against an empty array | 4,131 ms | 11.2 ms | 369× | each `remove` was inserted at the front of the patch | [#5461][5461] |
+| `diff()` of an array of 20,000 objects against every second one of them | 134 ms | 7.16 ms | 19× | the same | [#5461][5461] |
+| `parse()` with a callback that rejects half of 32,000 objects | 826 ms | 7.67 ms | 108× | each rejected value was searched for from the start of its parent | [#5457][5457] |
+| `<` on two equal values nested 24 levels deep (C++11 to C++17) | 53.8 ms | 0.004 ms | exponential | `std::vector`'s `<` asks `a < b` and `b < a`, and both recurse | [#5390][5390] |
+| `<` on `citm_catalog.json` and a copy, 10× (C++11 to C++17) | 270 ms | 3.78 ms | 71× | the same | [#5390][5390] |
+| `flatten()` of `citm_catalog.json` as `ordered_json` | 261 ms | 1.59 ms | 164× | every new key was looked up linearly | [#5834][5834] |
+| `to_bson()` of a value nested 200 levels deep, 100× | 19.6 ms | 0.392 ms | 50× | each document's size was computed by walking everything below it again | [#5553][5553], [#5979][5979] |
+| 100,000 × `push_back()` on an `ordered_json` with [`JSON_DIAGNOSTICS`](../../api/macros/json_diagnostics.md) | 1,515 ms | 0.936 ms | 1,619× | every insert re-pointed the parent pointers of all elements | [#5832][5832] |
+| 10,000 × `at(i)` on an `ordered_json` array with `JSON_DIAGNOSTICS` | 30.4 ms | 0.0095 ms | 3,204× | the same | [#5832][5832] |
Operations that were quadratic or worse in 3.12.0, timed with both versions (C++17,
-`-O3`, median of 3 interleaved runs).
Setup of the Google Benchmark comparison of 3.12.0 and 3.13.0.
**The other measurements.** The timeline is
[`tests/benchmarks/history`](https://github.com/nlohmann/json/tree/develop/tests/benchmarks/history): one program,
-compiled against `single_include` of 3.12.0, of each of the 358 commits on `develop` up to November 7 that changed
-`json.hpp` or `json_view.hpp` since, and of 3.13.0 (C++17, `-O3`, no LTO), 4 rounds in random order, median of the
-rounds (the mean of the two middle ones). Two commits that don't compile on their own are left out. The commits up to
-October 27 were run on October 27, those up to November 2 on November 3, and the later ones and 3.13.0 on November 7,
-each time together with twelve of the earlier commits as a check: per workload, their median moved by 1.5% or less
+compiled against `single_include` of 3.12.0 and of each of the 386 commits on `develop` up to 3.13.0 that changed
+`json.hpp` or `json_view.hpp` since (C++17, `-O3`, no LTO), 4 rounds in random order, median of the rounds (the mean of
+the two middle ones). Two commits that don't compile on their own are left out. The commits up to October 27 were run on
+October 27, those up to November 2 on November 3, those up to November 7 on November 7, and the later ones on November
+23, each time together with twelve of the earlier commits as a check: per workload, their median moved by 1.5% or less
(3% for `json_view`'s parse of `canada.json`, which only three of them have). The algorithmic fixes come from small
-extra programs (C++17, `-O3`, median of 3 interleaved runs). The comparison with other libraries is described in
+extra programs (C++17, `-O3`, median of 9 interleaved runs). The comparison with other libraries is described in
[Appendix E](#e-comparison-with-other-libraries).
**Compile times.** The two programs of [The price](#the-price), each compiled as one translation unit with `-std=c++20`
(modules need it) and `-O0` or `-O2`, with Apple clang 21 and Homebrew GCC 16.2 on the M1 Max. The time is the CPU time
-(user plus system) of the compiler process, the median of 5 rounds in which all 40 compilations ran in a random order.
-The slowest of the 5 runs was within 14% of the fastest for every program and every build of the precompiled header or
+(user plus system) of the compiler process, the median of 5 rounds. In each round, the 8 builds of the precompiled headers and
+modules ran first and the 32 compilations of the programs after them, each group in a random order. The slowest of the
+5 runs was within 15% of the fastest for every program and every build of the precompiled header or
the module. Every variant was also linked and run once, with the same output from all of them.
| build | program | 3.12.0 | 3.13.0 | 3.13.0, PCH | 3.13.0, module |
| --- | --- | --: | --: | --: | --: |
-| Apple clang `-O0` | `count_numbers` | 831 | 1,131 | 639 | 790 |
-| | `server_config` | 963 | 1,313 | 774 | 1,037 |
-| Apple clang `-O2` | `count_numbers` | 1,328 | 1,898 | 1,312 | 1,491 |
-| | `server_config` | 1,584 | 2,251 | 1,779 | 1,926 |
-| GCC 16 `-O0` | `count_numbers` | 1,417 | 2,385 | 1,593 | 1,604 |
-| | `server_config` | 1,878 | 2,820 | 2,152 | 2,180 |
-| GCC 16 `-O2` | `count_numbers` | 2,159 | 3,465 | 2,765 | 2,740 |
-| | `server_config` | 2,878 | 4,388 | 3,722 | 3,774 |
+| Apple clang `-O0` | `count_numbers` | 886 | 1,245 | 664 | 871 |
+| | `server_config` | 1,037 | 1,472 | 809 | 1,072 |
+| Apple clang `-O2` | `count_numbers` | 1,348 | 1,992 | 1,391 | 1,637 |
+| | `server_config` | 1,647 | 2,412 | 1,854 | 2,047 |
+| GCC 16 `-O0` | `count_numbers` | 1,514 | 2,490 | 1,667 | 1,652 |
+| | `server_config` | 1,948 | 2,926 | 2,192 | 2,208 |
+| GCC 16 `-O2` | `count_numbers` | 2,254 | 3,653 | 2,863 | 2,854 |
+| | `server_config` | 2,984 | 4,589 | 3,913 | 3,897 |
Compile time in milliseconds of the two programs in [The price](#the-price) (CPU
-time of the compiler, median of 5 runs). Building the precompiled header took 917 and 879 ms with Apple clang (`-O0`,
-`-O2`) and 2,306 and 2,264 ms with GCC; building the module took 1,399 and 1,433 ms or 2,339 and 2,325 ms.
+time of the compiler, median of 5 runs). Building the precompiled header took 918 and 944 ms with Apple clang (`-O0`,
+`-O2`) and 2,502 and 2,525 ms with GCC; building the module took 1,559 and 1,542 ms or 2,432 and 2,445 ms.
??? example "The programs and the build commands"
@@ -2703,14 +2729,15 @@ memory costs more page faults. We did not measure on Windows, and we did not mea
- 5 **Read the assembly:** stack canary [#5854][5854];
exceptions and inlining [#5838][5838], [#5840][5840], [#5839][5839], [#5836][5836]; aliasing [#5633][5633]; forced
inlining [#5878][5878]; branch-free selections [#5908][5908]; code size [#5902][5902]; the order of the iterator's
- type tests [#6039][6039].
+ type tests [#6039][6039]; forced inlining only when optimizing [#6117][6117].
- 6 **Write through a cursor:** write buffer [#5285][5285];
adapter on the stack [#5449][5449]; binary sinks [#5286][5286]; cursor and runs of numbers [#5824][5824],
[#5885][5885]; `to_bson()` in one pass [#5979][5979]; a window instead of zeroing the whole capacity [#6020][6020].
- 7 **Fix the algorithm first:** `diff()` [#5461][5461]; parse
callbacks [#5457][5457]; `operator<` [#5390][5390]; `flatten()` [#5834][5834]; `unflatten()` [#5793][5793]; JSON
Pointer and Patch [#5861][5861], [#5886][5886]; `to_bson()` [#5553][5553]; `JSON_DIAGNOSTICS` [#5832][5832]; bounded
- recursion [#5285][5285], [#5389][5389], [#5547][5547]; destructor [#5762][5762], [#5835][5835].
+ recursion [#5285][5285], [#5389][5389], [#5547][5547], [#6081][6081]; destructor [#5762][5762], [#5835][5835]; long keys
+ and paths [#6076][6076], [#6077][6077].
- 8 **Build a different data structure:** `json_document`
[#5620][5620], [#5627][5627], [#5628][5628], [#5622][5622], [#5908][5908], [#5879][5879]; `accept()` without an index
[#5970][5970]; reading and indexing [#5888][5888], [#5915][5915], [#5889][5889], [#5890][5890]; editing [#5630][5630],
@@ -2920,3 +2947,7 @@ These are the checks behind the themes:
[6031]: https://github.com/nlohmann/json/pull/6031
[6033]: https://github.com/nlohmann/json/pull/6033
[6039]: https://github.com/nlohmann/json/pull/6039
+[6076]: https://github.com/nlohmann/json/pull/6076
+[6077]: https://github.com/nlohmann/json/pull/6077
+[6081]: https://github.com/nlohmann/json/pull/6081
+[6117]: https://github.com/nlohmann/json/pull/6117
diff --git a/docs/mkdocs/docs/images/perf_blog_cliffs.svg b/docs/mkdocs/docs/images/perf_blog_cliffs.svg
index 422b818fa..01f11d5f2 100644
--- a/docs/mkdocs/docs/images/perf_blog_cliffs.svg
+++ b/docs/mkdocs/docs/images/perf_blog_cliffs.svg
@@ -1,6 +1,6 @@
diff --git a/docs/mkdocs/docs/images/perf_blog_distribution.svg b/docs/mkdocs/docs/images/perf_blog_distribution.svg
index 313897a5c..1ead01d8c 100644
--- a/docs/mkdocs/docs/images/perf_blog_distribution.svg
+++ b/docs/mkdocs/docs/images/perf_blog_distribution.svg
@@ -1,6 +1,6 @@