fu/FU/Benchmarks.pod
Yorhel ebe84167e7 jsonparse: A bunch of performance improvements
Turrns out JSON::XS had some pretty good ideas that I could borrow.
2025-01-31 18:42:21 +01:00

265 lines
8.4 KiB
Text

=head1 NAME
FU::Benchmarks - A bunch of automated benchmark results.
=head1 DESCRIPTION
This file is automatically generated from 'bench.PL' in the L<FU> distribution.
These benchmarks compare performance of some FU functionality against similar
modules found on CPAN.
B<DISCLAIMER#1:> Obtaining accurate measurements is notoriously hard. Take the
numbers below with a few buckets of salt, any difference below 10% is most
likely noise.
B<DISCLAIMER#2:> Goodhart's law: "When a measure becomes a target, it ceases to
be a good measure". I've used these benchmarks to find and optimize hotspots in
FU, which in turn means these numbers may look better than they are in
real-world use.
=head1 MODULE VERSIONS
The following module versions were used:
=over
=item L<Cpanel::JSON::XS> 4.38
=item L<FU> 0.1
=item L<JSON::PP> 4.16
=item L<JSON::SIMD> 1.06
=item L<JSON::XS> 4.03
=back
=head1 BENCHMARKS
=head2 JSON Formatting
These benchmarks run on large-ish arrays with repeated values. JSON encoding is
sufficiently fast that Perl function calling overhead tends to dominate for
smaller inputs, but I don't find that overhead very interesting.
Also worth noting that JSON::SIMD formatting code is forked from JSON::XS, the
SIMD parts are only used for parsing.
API object from L<JSON::XS> documentation.
Encode Canonical Decode
JSON::PP 5397/s 4973/s 1290/s
Cpanel::JSON::XS 112845/s 102903/s 101843/s
JSON::SIMD 125127/s 116569/s 117446/s
JSON::XS 128792/s 118616/s 117257/s
FU::Util 136151/s 115564/s 120184/s
Object (small)
Encode Canonical Decode
JSON::PP 905/s 827/s 206/s
Cpanel::JSON::XS 42755/s 27849/s 18920/s
JSON::SIMD 48487/s 30266/s 22527/s
JSON::XS 48980/s 30558/s 24065/s
FU::Util 49346/s 26316/s 20768/s
Object (large)
Encode Canonical Decode
JSON::PP 916/s 744/s 105/s
Cpanel::JSON::XS 29889/s 11629/s 16264/s
JSON::SIMD 33950/s 12050/s 22649/s
JSON::XS 34534/s 12399/s 23418/s
FU::Util 40482/s 13735/s 18161/s
Object (large, mixed unicode)
Encode Canonical Decode
JSON::PP 845/s 699/s 86/s
Cpanel::JSON::XS 20563/s 1402/s 7590/s
JSON::SIMD 24996/s 1401/s 15959/s
JSON::XS 26915/s 1454/s 8848/s
FU::Util 24706/s 11403/s 9379/s
Small integers
Encode Decode
JSON::PP 113/s 29/s
Cpanel::JSON::XS 7235/s 6008/s
JSON::SIMD 8058/s 4335/s
JSON::XS 8036/s 5998/s
FU::Util 8701/s 5902/s
Large integers
Encode Decode
JSON::PP 2174/s 330/s
Cpanel::JSON::XS 31337/s 48514/s
JSON::SIMD 36876/s 52446/s
JSON::XS 36665/s 48689/s
FU::Util 122700/s 62048/s
ASCII strings
Encode Decode
JSON::PP 2922/s 341/s
Cpanel::JSON::XS 117604/s 43652/s
JSON::SIMD 136214/s 50865/s
JSON::XS 136486/s 40599/s
FU::Util 192974/s 43327/s
Unicode strings
Encode Decode
JSON::PP 5144/s 254/s
Cpanel::JSON::XS 92871/s 66032/s
JSON::SIMD 106664/s 100555/s
JSON::XS 104716/s 60538/s
FU::Util 124756/s 49825/s
String escaping (few)
Encode Decode
JSON::PP 4258/s 350/s
Cpanel::JSON::XS 133222/s 104174/s
JSON::SIMD 155205/s 148939/s
JSON::XS 123154/s 92594/s
FU::Util 202792/s 85352/s
String escaping (many)
Encode Decode
JSON::PP 2230/s 360/s
Cpanel::JSON::XS 139049/s 99260/s
JSON::SIMD 152317/s 113037/s
JSON::XS 153421/s 107918/s
FU::Util 132523/s 78199/s
=cut
# Cached data used by bench.PL. Same as the formatted tables above but easier to parse.
json/api Canonical Cpanel::JSON::XS 102903
json/api Canonical FU::Util 115564
json/api Canonical JSON::PP 4973
json/api Canonical JSON::SIMD 116569
json/api Canonical JSON::XS 118616
json/api Decode Cpanel::JSON::XS 101843
json/api Decode FU::Util 120184
json/api Decode JSON::PP 1290
json/api Decode JSON::SIMD 117446
json/api Decode JSON::XS 117257
json/api Encode Cpanel::JSON::XS 112845
json/api Encode FU::Util 136151
json/api Encode JSON::PP 5397
json/api Encode JSON::SIMD 125127
json/api Encode JSON::XS 128792
json/intl Decode Cpanel::JSON::XS 48514
json/intl Decode FU::Util 62048
json/intl Decode JSON::PP 330
json/intl Decode JSON::SIMD 52446
json/intl Decode JSON::XS 48689
json/intl Encode Cpanel::JSON::XS 31337
json/intl Encode FU::Util 122700
json/intl Encode JSON::PP 2174
json/intl Encode JSON::SIMD 36876
json/intl Encode JSON::XS 36665
json/ints Decode Cpanel::JSON::XS 6008
json/ints Decode FU::Util 5902
json/ints Decode JSON::PP 29
json/ints Decode JSON::SIMD 4335
json/ints Decode JSON::XS 5998
json/ints Encode Cpanel::JSON::XS 7235
json/ints Encode FU::Util 8701
json/ints Encode JSON::PP 113
json/ints Encode JSON::SIMD 8058
json/ints Encode JSON::XS 8036
json/objl Canonical Cpanel::JSON::XS 11629
json/objl Canonical FU::Util 13735
json/objl Canonical JSON::PP 744
json/objl Canonical JSON::SIMD 12050
json/objl Canonical JSON::XS 12399
json/objl Decode Cpanel::JSON::XS 16264
json/objl Decode FU::Util 18161
json/objl Decode JSON::PP 105
json/objl Decode JSON::SIMD 22649
json/objl Decode JSON::XS 23418
json/objl Encode Cpanel::JSON::XS 29889
json/objl Encode FU::Util 40482
json/objl Encode JSON::PP 916
json/objl Encode JSON::SIMD 33950
json/objl Encode JSON::XS 34534
json/objs Canonical Cpanel::JSON::XS 27849
json/objs Canonical FU::Util 26316
json/objs Canonical JSON::PP 827
json/objs Canonical JSON::SIMD 30266
json/objs Canonical JSON::XS 30558
json/objs Decode Cpanel::JSON::XS 18920
json/objs Decode FU::Util 20768
json/objs Decode JSON::PP 206
json/objs Decode JSON::SIMD 22527
json/objs Decode JSON::XS 24065
json/objs Encode Cpanel::JSON::XS 42755
json/objs Encode FU::Util 49346
json/objs Encode JSON::PP 905
json/objs Encode JSON::SIMD 48487
json/objs Encode JSON::XS 48980
json/obju Canonical Cpanel::JSON::XS 1402
json/obju Canonical FU::Util 11403
json/obju Canonical JSON::PP 699
json/obju Canonical JSON::SIMD 1401
json/obju Canonical JSON::XS 1454
json/obju Decode Cpanel::JSON::XS 7590
json/obju Decode FU::Util 9379
json/obju Decode JSON::PP 86
json/obju Decode JSON::SIMD 15959
json/obju Decode JSON::XS 8848
json/obju Encode Cpanel::JSON::XS 20563
json/obju Encode FU::Util 24706
json/obju Encode JSON::PP 845
json/obju Encode JSON::SIMD 24996
json/obju Encode JSON::XS 26915
json/strel Decode Cpanel::JSON::XS 99260
json/strel Decode FU::Util 78199
json/strel Decode JSON::PP 360
json/strel Decode JSON::SIMD 113037
json/strel Decode JSON::XS 107918
json/strel Encode Cpanel::JSON::XS 139049
json/strel Encode FU::Util 132523
json/strel Encode JSON::PP 2230
json/strel Encode JSON::SIMD 152317
json/strel Encode JSON::XS 153421
json/stres Decode Cpanel::JSON::XS 104174
json/stres Decode FU::Util 85352
json/stres Decode JSON::PP 350
json/stres Decode JSON::SIMD 148939
json/stres Decode JSON::XS 92594
json/stres Encode Cpanel::JSON::XS 133222
json/stres Encode FU::Util 202792
json/stres Encode JSON::PP 4258
json/stres Encode JSON::SIMD 155205
json/stres Encode JSON::XS 123154
json/strs Decode Cpanel::JSON::XS 43652
json/strs Decode FU::Util 43327
json/strs Decode JSON::PP 341
json/strs Decode JSON::SIMD 50865
json/strs Decode JSON::XS 40599
json/strs Encode Cpanel::JSON::XS 117604
json/strs Encode FU::Util 192974
json/strs Encode JSON::PP 2922
json/strs Encode JSON::SIMD 136214
json/strs Encode JSON::XS 136486
json/stru Decode Cpanel::JSON::XS 66032
json/stru Decode FU::Util 49825
json/stru Decode JSON::PP 254
json/stru Decode JSON::SIMD 100555
json/stru Decode JSON::XS 60538
json/stru Encode Cpanel::JSON::XS 92871
json/stru Encode FU::Util 124756
json/stru Encode JSON::PP 5144
json/stru Encode JSON::SIMD 106664
json/stru Encode JSON::XS 104716