NAME
Surveyor::Benchmark::HTMLEntities - Benchmark HTML entity escaping
SYNOPSIS
Install Surveyor::App to get the survey
program.
To test the defaults:
% survey -p Surveyor::Benchmark::HTMLEntities URL
To compare pure Perl behavior:
% env PERL_ONLY=1 survey -p Surveyor::Benchmark::HTMLEntities URL
DESCRIPTION
HTML::Escape provides a limited functionality HTML entity escaper. It only handles ><&"'
. As such, it can be quite a bit faster because it does less.
Here are some numbers from my Mid-2012 MacBook Air:
XS versus pure Perl:
Benchmark: timing 10000 iterations of html_entities, html_escape...
html_entities: 14 wallclock secs (14.09 usr + 0.01 sys = 14.10 CPU) @ 709.22/s (n=10000)
html_escape: 1 wallclock secs ( 0.68 usr + 0.00 sys = 0.68 CPU) @ 14705.88/s (n=10000)
fair fight:
Benchmark: timing 10000 iterations of html_entities, html_escape...
html_entities: 14 wallclock secs (13.79 usr + 0.01 sys = 13.80 CPU) @ 724.64/s (n=10000)
html_escape: 7 wallclock secs ( 7.57 usr + 0.01 sys = 7.58 CPU) @ 1319.26/s (n=10000)
- set_up( URL )
-
Fetch the web page and store it for use in the benchmarks.
- tear_down
- bench_html_escape
-
Use HTML::Escape to encode. This is an XS module.
HTML::Escape only encodes the
><&"'
. - bench_html_entities
-
Use HTML::Entities to encode. This is an pure Perl module.
I tell
encode_entities
to only encode><&"'
so it matches what HTML::Escape will do. Otherwise,encode_entities
escapes wide characters too.
TO DO
SEE ALSO
SOURCE AVAILABILITY
This source is in Github:
https://github.com/briandfoy/surveyor-benchmark-htmlentities
AUTHOR
brian d foy, <briandfoy@pobox.com>
COPYRIGHT AND LICENSE
Copyright © 2013-2024, brian d foy <briandfoy@pobox.com>. All rights reserved.
You may redistribute this under the terms of Artistic License 2.0.