Created
August 15, 2013 07:28
-
-
Save ytnobody/6238919 to your computer and use it in GitHub Desktop.
compare engine benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Benchmark qw(:all); | |
use Test::Deep::NoTest; | |
use Data::Compare; | |
{ | |
package Data::Compare::Deparse; | |
use B::Deparse; | |
my $deparser = B::Deparse->new(); | |
sub compare { | |
my ($class, $x, $y) = @_; | |
my $_x = $deparser->coderef2text(sub{$x}); | |
my $_y = $deparser->coderef2text(sub{$y}); | |
return $_x eq $_y ? 1 : undef; | |
} | |
} | |
my $count = 10000; | |
my $x = { foo => 'bar', a => [qw/1 2 3/] }; | |
my $y = { foo => 'bar', a => [qw/1 2 3/] }; | |
my $z = { foo => 'bar', b => [qw/1 2 3/] }; | |
my $res = timethese($count, { | |
T_D_NoTest => sub { eq_deeply($x, $y); eq_deeply($x, $z) }, | |
D_Compare => sub { Compare($x, $y); Compare($x, $z) }, | |
D_C_Deparse => sub { Data::Compare::Deparse->compare($x, $y); Data::Compare::Deparse->compare($x, $z) }, | |
}); | |
cmpthese($res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment