Skip to content

Instantly share code, notes, and snippets.

@dakkar
Last active May 4, 2016 11:15
Show Gist options
  • Save dakkar/eac6a7ad32d8e91ef2f8a95af55e7598 to your computer and use it in GitHub Desktop.
Save dakkar/eac6a7ad32d8e91ef2f8a95af55e7598 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark;
use List::Util;
my @keys = List::Util::shuffle( (1..500) x 1000, 600..800 );
Benchmark::cmpthese(-5, {
with_test => 'my %h; for my $k (@keys) { $h{$k}=1 unless exists $h{$k} }',
no_test => 'my %h; for my $k (@keys) { $h{$k}=1 }',
});
Rate with_test no_test
with_test 1852124/s -- -0%
no_test 1852549/s 0% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment