Skip to content

Instantly share code, notes, and snippets.

@mash
Created June 5, 2009 10:53
Show Gist options
  • Save mash/124224 to your computer and use it in GitHub Desktop.
Save mash/124224 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Data::UUID;
use Digest::SHA1 qw/sha1_hex/;
use Benchmark qw/cmpthese/;
my $uuid_generator = new Data::UUID;
cmpthese( 10000, {
pre_generate => sub {
sha1_hex( $uuid_generator->create );
},
generate_per_request => sub {
sha1_hex( Data::UUID->new->create );
},
});
santrini% ./uuid_bench.pl
(warning: too few iterations for a reliable count)
Rate generate_per_request pre_generate
generate_per_request 8403/s -- -97%
pre_generate 250000/s 2875% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment