Skip to content

Instantly share code, notes, and snippets.

@kan
Created January 18, 2010 03:54
Show Gist options
  • Save kan/279769 to your computer and use it in GitHub Desktop.
Save kan/279769 to your computer and use it in GitHub Desktop.
Benchmark: timing 20 iterations of data_recursive, data_visitor...
data_recursive: 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)
(warning: too few iterations for a reliable count)
data_visitor: 1 wallclock secs ( 0.19 usr + 0.29 sys = 0.48 CPU) @ 41.67/s (n=20)
Rate data_visitor data_recursive
data_visitor 41.7/s -- -100%
data_recursive 20000000000000000/s 48000000000000000% --
cat ./bench.pl
use strict;
use warnings;
use utf8;
use Benchmark qw(:all);
use lib './lib';
use Data::Visitor::Encode;
use Data::Recursive::Encode;
my $sample = { key => ["これはサンプルです","これはサンプルです"] };
my $cmp = timethese(
20,
{
data_recursive => sub { Data::Recursive::Encode->encode('utf8', $sample) },
data_visitor => sub { Data::Visitor::Encode->encode('utf8', $sample) },
}
);
cmpthese $cmp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment