Add benchmarking tool + improve integer formatting performance

Typical priorities: make it fast before fixing all the bugs. *shrug*
This commit is contained in:
Yorhel 2025-01-28 14:49:29 +01:00
parent c16a9fa493
commit 9c8ce3f782
4 changed files with 259 additions and 13 deletions

101
FU/Benchmarks.pod Normal file
View file

@ -0,0 +1,101 @@
=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.
=head1 CONTEXT
These benchmarks were performed on 2025-01-28 with perl v5.40.0 on x86_64-linux.
The following module versions were used:
=over
=item L<FU> 0.1
=item L<Cpanel::JSON::XS> 4.38
=item L<JSON::PP> 4.16
=item L<JSON::XS> 4.03
=item L<JSON::SIMD> 1.06
=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. Other modules
will likely do better in benchmarks on small inputs.
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.
JSON::PP 5370/s
Cpanel::JSON::XS 112211/s
JSON::SIMD 128743/s
JSON::XS 130606/s
FU::Util 130813/s
Small integers
JSON::PP 113/s
Cpanel::JSON::XS 7262/s
JSON::SIMD 8217/s
JSON::XS 8142/s
FU::Util 9154/s
Large integers
JSON::PP 2136/s
Cpanel::JSON::XS 29220/s
JSON::SIMD 35834/s
JSON::XS 35879/s
FU::Util 117838/s
ASCII strings
JSON::PP 2893/s
Cpanel::JSON::XS 118698/s
JSON::SIMD 137235/s
JSON::XS 135933/s
FU::Util 172207/s
Unicode strings
JSON::PP 5186/s
Cpanel::JSON::XS 97154/s
JSON::SIMD 109441/s
JSON::XS 105691/s
FU::Util 106058/s
String escaping (few)
JSON::PP 4280/s
Cpanel::JSON::XS 140105/s
JSON::SIMD 161231/s
JSON::XS 160077/s
FU::Util 182074/s
String escaping (many)
JSON::PP 2235/s
Cpanel::JSON::XS 144829/s
JSON::SIMD 161006/s
JSON::XS 161246/s
FU::Util 136568/s