++ed by:
MUTO MHOWARD AKIYM

3 PAUSE users
1 non-PAUSE user.

sysread

BENCHMARKS

Various operations comparing URI::Fast against URI's performance. The script to recreate is included in the bench folder of the distribution.

Tests were performed on my development machine, a 2015 MacBook Pro (2.7 GHz Intel Core i5, 8GB 1867 MHz DDR3 RAM) using Perl 5.24 installed using perlbrew.

};

my @urls = ( '/foo/bar/baz', 'http://www.test.com', 'https://test.com/some/path?aaaa=bbbb&cccc=dddd&eeee=ffff', 'https://user:pwd@192.168.0.1:8000/foo/bar?baz=bat&slack=fnord&asdf=the+quick%20brown+fox+%26+hound#foofrag', );

my $encode_input = "Ῥόδος¢€" . q{! * ' ( ) ; : @ & = + $ , / ? # [ ] %} x 10; my $decode_input = URI::Fast::encode($encode_input);

sub test { my ($msg, $count, $tests) = @_; local $| = 1;

  print "> $msg\n";
  my $results = cmpthese $count, $tests;

  print $POD "=head2 $msg\n\n";

  foreach (@$results) {
    printf $POD "  %15s%15s%15s%15s\n", @$_;
  }

  print $POD "\n\n";

  print "\n";
}

test 'Constructor', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]) }, 'URI::Fast' => sub{ my $uri = uri $urls[3] }, };

test 'Parse scheme', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); $uri->scheme }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; $uri->scheme }, };

test 'Update scheme', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[1]); $uri->scheme('https') }, 'URI::Fast' => sub{ my $uri = uri $urls[1]; $uri->scheme('https') }, };

test 'Parse authorization', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); $uri->host }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; $uri->host }, };

test 'Update authorization', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); $uri->host('test.com') }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; $uri->host('test.com') }, };

test 'Parse path (scalar)', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); my $p = $uri->path }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; my $p = $uri->path }, };

test 'Parse path (list)', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); my @p = $uri->path_segments }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; my @p = $uri->path }, };

test 'Update path (scalar)', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); $uri->path('/foo/bar') }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; $uri->path('/foo/bar') }, };

test 'Update path (array)', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); $uri->path('/' . join('/', 'foo', 'bar')) }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; $uri->path(['foo', 'bar']) }, };

test 'Parse query', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); my %q = $uri->query_form }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; my @v = $uri->param('asdf') }, };

test 'Set query parameter', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); $uri->query_form(foo => 'bar') }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; $uri->param('foo', 'bar') }, };

test 'Query form', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); my %q = $uri->query_form }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; my $q = $uri->query_hash }, };

test 'Query keys', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); my @k = keys %{$uri->query_form} }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; my @k = $uri->query_keys }, };

test 'Stringification', 1_000_000, { 'URI' => sub{ my $uri = URI->new($urls[3]); my $str = "$uri" }, 'URI::Fast' => sub{ my $uri = uri $urls[3]; my $str = "$uri" }, };

test 'uri_split', 1_000_000, { 'URI::Split' => sub{ my @uri = URI::Split::uri_split($urls[3]) }, 'URI::Fast' => sub{ my @uri = uri_split($urls[3]) }, };

test 'Encode', 2_000_000, { 'URI::Encode::XS' => sub{ uri_encode_utf8($encode_input) }, 'URI::Fast' => sub{ URI::Fast::encode($encode_input) }, };

test 'Decode', 2_000_000, { 'URI::Encode::XS' => sub{ uri_decode_utf8($decode_input) }, 'URI::Fast' => sub{ URI::Fast::decode($decode_input) }, };

close $POD;

1 POD Error

The following errors were encountered while parsing the POD:

Around line 39:

Non-ASCII character seen before =encoding in '"Ῥόδος¢€"'. Assuming UTF-8