Skip to content

Instantly share code, notes, and snippets.

@ziguzagu
Last active February 10, 2016 06:10
Show Gist options
  • Save ziguzagu/987782c34bc8558e6086 to your computer and use it in GitHub Desktop.
Save ziguzagu/987782c34bc8558e6086 to your computer and use it in GitHub Desktop.
URI vs URI::Split (v1.60)
#!/usr/bin/env perl
use strict;
use warnings; use utf8;
use Benchmark qw(cmpthese);
use URI;
use URI::Split qw(uri_split);
my $uri = 'https://www.example.com/path/2016/10/my-awesome-photo.jpg?utm=aaa#anchor1';
cmpthese(200000, {
'URI' => sub {
URI->new($uri)->path;
},
'URI::Split' => sub {
(uri_split($uri))[2];
},
});
# Rate URI URI::Split
# URI 35524/s -- -92%
# URI::Split 465116/s 1209% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment