leptris 1.9.210.1 → 1.9.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Rakefile +1 -1
- data/lib/leptris/vendor/aarch64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/version.rb +1 -1
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +57 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/TODO.max-perf/00-INDEX.md +4 -0
- data/vendor-src/libleptris/TODO.max-perf/interleaved-parse.md +67 -0
- data/vendor-src/libleptris/benchmarks/CMakeLists.txt +13 -0
- data/vendor-src/libleptris/benchmarks/parse/bench_parse_ab.cpp +83 -0
- data/vendor-src/libleptris/src/leptris/flat/direct_parse.c +658 -0
- data/vendor-src/libleptris/src/leptris/leptris_internal.h +1 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_operators.c +368 -1
- data/vendor-src/libleptris/src/leptris/xpath/functions_ext31.c +466 -24
- data/vendor-src/libleptris/src/leptris/xpath/parser.c +69 -7
- data/vendor-src/libleptris/src/leptris/xpath/vm.c +3 -1
- data/vendor-src/libleptris/src/leptris/xpath/xpath_internal.h +8 -1
- data/vendor-src/libleptris/src/leptris/xslt/xslt_exec.c +5 -2
- data/vendor-src/libleptris/src/leptris/xslt/xslt_internal.h +9 -0
- data/vendor-src/libleptris/test/CMakeLists.txt +1 -0
- data/vendor-src/libleptris/test/parser/test_interleaved.cpp +223 -0
- data/vendor-src/libleptris/test/xpath/test_xpath.cpp +4 -1
- data/vendor-src/libleptris/test/xquery/qt3/README.md +12 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/day-from-date.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/day-from-dateTime.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/hours-from-dateTime.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/hours-from-time.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/implicit-timezone.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/minutes-from-dateTime.xml +250 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/minutes-from-time.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/month-from-date.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/month-from-dateTime.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/parse-ietf-date.xml +1268 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/seconds-from-dateTime.xml +250 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/seconds-from-time.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/timezone-from-date.xml +333 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/timezone-from-dateTime.xml +250 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/timezone-from-time.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/year-from-date.xml +253 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/year-from-dateTime.xml +249 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-dayTimeDuration-to-date.xml +467 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-dayTimeDuration-to-dateTime.xml +436 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-dayTimeDuration-to-time.xml +432 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-dayTimeDurations.xml +850 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-yearMonthDuration-to-date.xml +441 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-yearMonthDuration-to-dateTime.xml +305 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/add-yearMonthDurations.xml +440 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/dayTimeDuration-greater-than.xml +859 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/dayTimeDuration-less-than.xml +685 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/divide-dayTimeDuration-by-dayTimeDuration.xml +410 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/divide-dayTimeDuration.xml +807 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/divide-yearMonthDuration-by-yearMonthDuration.xml +377 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/divide-yearMonthDuration.xml +499 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/duration-equal.xml +1477 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/multiply-dayTimeDuration.xml +697 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/multiply-yearMonthDuration.xml +685 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-dayTimeDuration-from-date.xml +377 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-dayTimeDuration-from-dateTime.xml +376 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-dayTimeDuration-from-time.xml +441 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-dayTimeDurations.xml +971 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-yearMonthDuration-from-date.xml +426 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-yearMonthDuration-from-dateTime.xml +377 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/subtract-yearMonthDurations.xml +531 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/yearMonthDuration-greater-than.xml +542 -0
- data/vendor-src/libleptris/test/xquery/qt3/op/yearMonthDuration-less-than.xml +542 -0
- data/vendor-src/libleptris/test/xquery/test_qt3.cpp +128 -3
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +47 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 708246fd0d69af25b4257d67e0c22a62a818c5aa7e523eb914628c011b6065e3
|
|
4
|
+
data.tar.gz: 386676e6428cbb3aa09b9bb490516e438465570302ac0024a0b13ebafc545d4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19826be07b804dca192cef9777f88f804b077c87a44cc0b24940509ae1db6787391c9e1db63acfad547fbeef910c03fc79ac345e064cb6b32a7ecedfdd9ec500
|
|
7
|
+
data.tar.gz: b24ae844a86ac307c39164b096cf5ba5fbb5a11cf981d9c1ca5573fdf9b6a0f14968074c73e47e1d9c3ba7143a57fa2e00ba616575750dbacf5c00be70ca3fef
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ All notable changes to Leptris will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.9.213.0] - 2026-09-21
|
|
9
|
+
|
|
10
|
+
### Engine sync — 1.9.211–1.9.213 (perf + the QT3 date/time family)
|
|
11
|
+
|
|
12
|
+
- 1.9.211: the **interleaved parse lane** landed behind
|
|
13
|
+
`LEPTRIS_INTERLEAVED=1` (engine-side opt-in; sentinel-discipline
|
|
14
|
+
scans, fused 48-byte SIMD probes, names as zero-copy views —
|
|
15
|
+
1633/1633 parity). The XSLT append-tail memo (single-slot
|
|
16
|
+
validated last-child hint) also rides.
|
|
17
|
+
- 1.9.212/1.9.213: the **QT3 date/time function family** for
|
|
18
|
+
XPath/XSLT (extractors, timezone + `fn:parse-ietf-date`,
|
|
19
|
+
`op:date` arithmetic, the yearMonthDuration family — 17 test
|
|
20
|
+
sets, 782/782 engine-side) plus int64/`long long` portability
|
|
21
|
+
fixes for MSVC/ILP32.
|
|
22
|
+
- No binding-facing surface changes: audit holds at 335/335,
|
|
23
|
+
suite 760/0.
|
|
24
|
+
|
|
8
25
|
## [Unreleased]
|
|
9
26
|
|
|
10
27
|
### Added — Descriptor typed scalars + the fused materialize entry (#230's consumer contract)
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.213"
|
|
12
12
|
# Vendored alongside libleptris for fn:normalize-unicode (TODO
|
|
13
13
|
# .restructure/20): built per platform with a RELOCATABLE @rpath
|
|
14
14
|
# install name, loaded by ffi.rb before libleptris so the
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/leptris/version.rb
CHANGED
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.213] - 2026-09-21
|
|
4
|
+
|
|
5
|
+
### Added — the op:date and yearMonth families (#1182, lever 6)
|
|
6
|
+
|
|
7
|
+
- **op-date arithmetic (#1265)**: date/time/dateTime +/- dayTimeDuration — 6 QT3 sets, 128/128. Shared lexical shifter (`leptris_dt_shift`), time arithmetic wrapping the day, ISO date-shaped string comparisons. Fixed two corpus-caught bugs: zoned times misclassified as dateTimes, and dateTime results printing the input's seconds instead of the shifted instant's.
|
|
8
|
+
- **yearMonthDuration family (#1266)**: 11 QT3 sets, 264/264 — months arithmetic (PnYnM canonical, llrint tie rule), month-end clamping for date/dateTime shifts (leap-aware), negative-year printing. The lt/gt sets rode the existing months comparison hook untouched.
|
|
9
|
+
|
|
10
|
+
Both batches survived the 32-bit-long portability classes (MSVC/ILP32): int64-range instant math and every %lld argument now use long long — the CI legs caught three occurrences of the width/specifier mismatch family.
|
|
11
|
+
|
|
12
|
+
## [1.9.212] - 2026-09-21
|
|
13
|
+
|
|
14
|
+
### Added — the QT3 date/time family (lever 6 stage-2, #1182)
|
|
15
|
+
|
|
16
|
+
Three corpus-driven batches land the date/time surface with the
|
|
17
|
+
W3C QT3 suite as the gate:
|
|
18
|
+
|
|
19
|
+
- **Extractors (#1261)**: 12 vendored test-sets (300/300) —
|
|
20
|
+
year/month/day-from-date{,Time}, hours/minutes/seconds-from-
|
|
21
|
+
{time,dateTime} — plus five language fixes: function-call
|
|
22
|
+
operands for eq/ne/lt/le/gt/ge (unprefixed and fn:-prefixed),
|
|
23
|
+
the `idiv` operator, unary `+`, the timezone scan in date
|
|
24
|
+
parsing (zoned values were treated as naive), and the
|
|
25
|
+
empty-sequence/fractional-seconds extractor contracts.
|
|
26
|
+
- **Timezone + RFC 5322 (#1262)**: 5 sets (90/90) —
|
|
27
|
+
timezone-from-* accessors and fn:parse-ietf-date (both lexical
|
|
28
|
+
orders, obsolete US zones, verbatim fractions). The QT3 harness
|
|
29
|
+
grew inline param environments and external-declaration
|
|
30
|
+
prepending.
|
|
31
|
+
- **op:dayTimeDuration value model (#1263)**: 8 sets (287/287) —
|
|
32
|
+
duration arithmetic (+, -, *, div), comparisons, min/max over
|
|
33
|
+
duration sequences, canonical formatting, FODT0002 range errors
|
|
34
|
+
(including a fixed fortified-runtime abort on giant values), and
|
|
35
|
+
adjust-* attaching the implicit timezone to naive values.
|
|
36
|
+
|
|
37
|
+
## [1.9.211] - 2026-09-20
|
|
38
|
+
|
|
39
|
+
### Performance
|
|
40
|
+
|
|
41
|
+
- **Interleaved parse lane, slices 1-3a (#1258).** The first
|
|
42
|
+
pugixml-style interleaved rewrite landed behind
|
|
43
|
+
`LEPTRIS_INTERLEAVED=1` (opt-in; every input outside the covered
|
|
44
|
+
surface bails to the classic parser before any state). The lane
|
|
45
|
+
streams `IlRec`/`IlAttr` records with buffer-relative views, then
|
|
46
|
+
replays the classic public stores in one linear post-pass:
|
|
47
|
+
sentinel-discipline scans (no per-byte bounds tests; fused 48-byte
|
|
48
|
+
quote/'&'/whitespace probes with SIMD tails), upfront stream
|
|
49
|
+
capacity from the input size, and element/attribute names as
|
|
50
|
+
NUL'd views into the parse scratch (no per-name copies). Parity is
|
|
51
|
+
gated by a dedicated spec plus running the FULL test suite with
|
|
52
|
+
the lane forced on: 1633/1633 identical. `LEPTRIS_IL_STATS=1`
|
|
53
|
+
prints an engagement canary for diagnosing whether the lane ran.
|
|
54
|
+
- **XSLT append-tail memo (#1259).** `out_append_child` keeps a
|
|
55
|
+
validated single-slot (parent, last-child) hint and feeds
|
|
56
|
+
`leptris_element_append_child_tail` — result-tree placement no
|
|
57
|
+
longer re-walks sibling chains (the hottest dispatch-heavy
|
|
58
|
+
profile leaf, ~17% of samples).
|
|
59
|
+
|
|
3
60
|
## [1.9.210] - 2026-09-20
|
|
4
61
|
|
|
5
62
|
### Added
|
|
@@ -24,3 +24,7 @@ Next portability gate: s390x big-endian (#1194, PR #1202).
|
|
|
24
24
|
The node-layout fork (row 4 successor, owner green-lit 2026-09-20):
|
|
25
25
|
TODO.max-perf/node-layout-fork.md — 5 slices, addresses #1222 +
|
|
26
26
|
#1179 residual + #1238 parse side.
|
|
27
|
+
|
|
28
|
+
The interleaved-parse rewrite (owner-directed 2026-09-20):
|
|
29
|
+
TODO.max-perf/interleaved-parse.md — the #1222 step-change; slices 0-4,
|
|
30
|
+
each CI-benchmark-gated.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# The interleaved-parse rewrite (the pugixml-class lane)
|
|
2
|
+
|
|
3
|
+
Status: PLAN (2026-09-20, owner directive). Supersedes the fork's
|
|
4
|
+
remaining slices for the XML parse path. Target: close the #1222
|
|
5
|
+
large-document gap (pugixml 2-5.9x ahead on CI) at the SOURCE.
|
|
6
|
+
|
|
7
|
+
## Why the current lane can't get there
|
|
8
|
+
|
|
9
|
+
The no-LTO dissection (2026-09-20) shows direct_parse is at its
|
|
10
|
+
representation optimum: fused 48B probe + SIMD value scan, packed
|
|
11
|
+
attr tail, O(1) wiring, offset edges, root-only registration. The
|
|
12
|
+
remaining per-item cost is the representation itself: per-attr
|
|
13
|
+
40B struct stores inline in the parse loop, the scratch
|
|
14
|
+
NUL-terminate/restore dance, per-element ns/line bookkeeping, and
|
|
15
|
+
the O(K) dup-detection walk.
|
|
16
|
+
|
|
17
|
+
## The pugixml model (what we're adopting)
|
|
18
|
+
|
|
19
|
+
One immutable input (already ours, #1125) + ONE node region + ONE
|
|
20
|
+
stream region. The parse loop ONLY appends to streams; nothing is
|
|
21
|
+
finalized inline:
|
|
22
|
+
|
|
23
|
+
1. **SOA attr streams** — per element, attrs land in parallel
|
|
24
|
+
arrays: name_off[4B] / value_off[4B] / len8[len pairs] into the
|
|
25
|
+
string stream. ~12-16B per attr, sequential stores, no structs
|
|
26
|
+
built during parse.
|
|
27
|
+
2. **Length-based views everywhere** — names and values are
|
|
28
|
+
(offset, len) into the pristine buffer. NO NUL-termination, NO
|
|
29
|
+
scratch mutation, NO restore pass (the current lane's biggest
|
|
30
|
+
hidden cost).
|
|
31
|
+
3. **Element records as pure data** — a 32-48B record per element
|
|
32
|
+
(name view, first_attr index, parent/first/next indices, line)
|
|
33
|
+
bump-carved from the node region (doc_block, slice 1 landed).
|
|
34
|
+
4. **Deferred passes** — dup detection, ns stamping, hash
|
|
35
|
+
sentinel: all become ONE linear post-pass sweep over the
|
|
36
|
+
streams (cache-sequential), building the public
|
|
37
|
+
leptris_attribute structs. The public API, DOM semantics, and
|
|
38
|
+
every consumer see IDENTICAL trees.
|
|
39
|
+
|
|
40
|
+
## Slices (one PR each, CI-benchmark-gated)
|
|
41
|
+
|
|
42
|
+
0. **A/B harness**: bench_parse_ab in benchmarks/ — the attr/text
|
|
43
|
+
shapes at 1.5/5/13MB, leptris vs pugixml vs libxml2, run by the
|
|
44
|
+
CI Benchmark legs on QUIET runners (the local Mac under load
|
|
45
|
+
343 produced 46-85 MB/s phantom numbers — measurements gate on
|
|
46
|
+
CI only). PR with this plan.
|
|
47
|
+
1. **The dp_il lane skeleton** (flag off): streams + records +
|
|
48
|
+
post-pass building the public tree for well-formed, DTD-free
|
|
49
|
+
input. Gate: parity specs byte-identical to the current lane;
|
|
50
|
+
CI A/B numbers recorded.
|
|
51
|
+
2. **Tokenizer port**: the SIMD scan helpers onto the stream
|
|
52
|
+
appends. Gate: attr shape ≤1.5x pugixml, text ≤1.25x on CI.
|
|
53
|
+
3. **Feature coverage**: DTD/entity/namespace/CDATA/PI routes
|
|
54
|
+
through the lane (fall back to the classic lane per-feature,
|
|
55
|
+
never wrong). Gate: full ctest + html5lib-style parity for the
|
|
56
|
+
XML suite (W3C + libxml2 corpus green).
|
|
57
|
+
4. **Default flip**: LEPTRIS_PARSE_INTERLEAVED=1 default, classic
|
|
58
|
+
lane behind an env escape hatch. Gate: all 24 CI legs + a
|
|
59
|
+
release cut with the CI A/B table in the notes.
|
|
60
|
+
|
|
61
|
+
## Invariants (non-negotiable)
|
|
62
|
+
|
|
63
|
+
- Public API/ABI unchanged; every existing spec passes unmodified.
|
|
64
|
+
- The classic lane stays until slice 4 ships AND one full release
|
|
65
|
+
runs clean.
|
|
66
|
+
- Zero-copy views remain primary; the pristine buffer is never
|
|
67
|
+
mutated by the interleaved lane.
|
|
@@ -232,6 +232,19 @@ leptris_add_benchmark(bench_xslt_subtree_copy xslt/bench_subtree_copy.c utils.c)
|
|
|
232
232
|
# ----------------------------------------------------------------------------
|
|
233
233
|
leptris_add_benchmark(bench_iterparse sax/bench_iterparse.c)
|
|
234
234
|
|
|
235
|
+
# Interleaved-parse gate (#1222): leptris vs pugixml on identical
|
|
236
|
+
# fixtures, run by the CI Benchmark legs (quiet runners).
|
|
237
|
+
if(PUGIXML_AVAILABLE)
|
|
238
|
+
leptris_add_benchmark(bench_parse_ab CXX parse/bench_parse_ab.cpp)
|
|
239
|
+
target_compile_definitions(bench_parse_ab PRIVATE HAVE_PUGIXML=1)
|
|
240
|
+
if(PUGIXML_TARGET)
|
|
241
|
+
target_link_libraries(bench_parse_ab PRIVATE ${PUGIXML_TARGET})
|
|
242
|
+
else()
|
|
243
|
+
target_include_directories(bench_parse_ab PRIVATE ${PUGIXML_INCLUDE_DIR})
|
|
244
|
+
target_link_libraries(bench_parse_ab PRIVATE ${PUGIXML_LIBRARY})
|
|
245
|
+
endif()
|
|
246
|
+
endif()
|
|
247
|
+
|
|
235
248
|
# ----------------------------------------------------------------------------
|
|
236
249
|
# SAX benchmarks (leptris vs libxml2). TODO 101.
|
|
237
250
|
# ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* bench_parse_ab.cpp — the interleaved-parse lane's gate (#1222).
|
|
2
|
+
*
|
|
3
|
+
* Same fixtures, sizes, and shapes for leptris and pugixml,
|
|
4
|
+
* best-of-5 each. The CI Benchmark legs run this on quiet
|
|
5
|
+
* runners; the interleaved lane's slices are gated on THESE
|
|
6
|
+
* numbers, never a loaded dev machine (2026-09-20: a Mac at load
|
|
7
|
+
* 340 measured a 472 MB/s build at 46-85).
|
|
8
|
+
*/
|
|
9
|
+
#include <stdio.h>
|
|
10
|
+
#include <stdlib.h>
|
|
11
|
+
#include <string.h>
|
|
12
|
+
#include <time.h>
|
|
13
|
+
#include "leptris.h"
|
|
14
|
+
#ifdef HAVE_PUGIXML
|
|
15
|
+
#include "pugixml.hpp"
|
|
16
|
+
using namespace pugi;
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
static double now_us(void) {
|
|
20
|
+
struct timespec ts;
|
|
21
|
+
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
22
|
+
return ts.tv_sec * 1e6 + ts.tv_nsec / 1e3;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static size_t gen(char* out, size_t target, int text_shape) {
|
|
26
|
+
size_t len = 0;
|
|
27
|
+
len += (size_t)sprintf(out + len, "<root>");
|
|
28
|
+
int i = 0;
|
|
29
|
+
if (text_shape) {
|
|
30
|
+
while (len < target)
|
|
31
|
+
len += (size_t)sprintf(out + len,
|
|
32
|
+
"<p>The quick brown fox jumps over the lazy dog %d.</p>", i++);
|
|
33
|
+
} else {
|
|
34
|
+
while (len < target)
|
|
35
|
+
len += (size_t)sprintf(out + len,
|
|
36
|
+
"<item id=\"%d\" class=\"c%d\" state=\"on\" ref=\"%d\">v %d</item>",
|
|
37
|
+
i, i % 7, i * 3, i++);
|
|
38
|
+
}
|
|
39
|
+
len += (size_t)sprintf(out + len, "</root>");
|
|
40
|
+
return len;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
int main(void) {
|
|
44
|
+
const size_t sizes[3] = {1500 * 1024, 5000 * 1024, 13000 * 1024};
|
|
45
|
+
const char* names[2] = {"attr", "text"};
|
|
46
|
+
printf("%-6s %9s %12s %12s\n", "shape", "bytes", "leptris", "pugixml");
|
|
47
|
+
for (int s = 0; s < 2; s++) {
|
|
48
|
+
for (size_t si = 0; si < 3; si++) {
|
|
49
|
+
char* doc = (char*)malloc(sizes[si] + 2048);
|
|
50
|
+
if (!doc) return 1;
|
|
51
|
+
size_t len = gen(doc, sizes[si], s);
|
|
52
|
+
double best = 1e18;
|
|
53
|
+
for (int r = 0; r < 5; r++) {
|
|
54
|
+
double a = now_us();
|
|
55
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
56
|
+
LeptrisDocument d = leptris_parse_string(doc, len, &st);
|
|
57
|
+
double b = now_us();
|
|
58
|
+
if (!d) { printf("PARSE FAILED\n"); return 1; }
|
|
59
|
+
leptris_document_free(d);
|
|
60
|
+
if (b - a < best) best = b - a;
|
|
61
|
+
}
|
|
62
|
+
double mbps = len / 1048576.0 / (best / 1e6);
|
|
63
|
+
#ifdef HAVE_PUGIXML
|
|
64
|
+
double pbest = 1e18;
|
|
65
|
+
for (int r = 0; r < 5; r++) {
|
|
66
|
+
double a = now_us();
|
|
67
|
+
xml_document xdoc;
|
|
68
|
+
xml_parse_result res = xdoc.load_buffer(doc, len);
|
|
69
|
+
double b = now_us();
|
|
70
|
+
if (!res) { printf("PUGIXML FAILED: %s\n", res.description()); return 1; }
|
|
71
|
+
if (b - a < pbest) pbest = b - a;
|
|
72
|
+
}
|
|
73
|
+
double pmbps = len / 1048576.0 / (pbest / 1e6);
|
|
74
|
+
printf("%-6s %9zu %10.1f %10.1f MB/s (pugixml %.2fx)\n",
|
|
75
|
+
names[s], len, mbps, pmbps, pmbps / mbps);
|
|
76
|
+
#else
|
|
77
|
+
printf("%-6s %9zu %10.1f %10s\n", names[s], len, mbps, "-");
|
|
78
|
+
#endif
|
|
79
|
+
free(doc);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return 0;
|
|
83
|
+
}
|