Created
June 1, 2015 16:08
-
-
Save Tux/5fd68abcc5f362ede112 to your computer and use it in GitHub Desktop.
This file contains 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
#!perl6 | |
# speed.pl: compare different versions of Text-CSV* modules | |
# (m)'15 [01 Jun 2015] Copyright H.M.Brand 2007-2015 | |
use v6; | |
use Slang::Tuxic; | |
use Text::CSV; | |
use Bench; | |
#use Benchmark qw(:all :hireswallclock); | |
my $csv = Text::CSV.new (eol => "\n"); | |
my $duration = (@*ARGS.shift // 2).Int; | |
my Str @fields1 = ( | |
"Wiedmann", "Jochen", | |
"Am Eisteich 9", | |
"72555 Metzingen", | |
"Germany", | |
"+49 7123 14881", | |
"joe\@ispsoft,de"); | |
my @fields10 = (@fields1) xx 10; | |
my @fields100 = (@fields1) xx 100; | |
$csv.combine (@fields1 ); my $str1 = $csv.string; | |
$csv.combine (@fields10 ); my $str10 = $csv.string; | |
$csv.combine (@fields100); my $str100 = $csv.string; | |
Bench.new.timethese (100, { | |
"combine 1" => sub { $csv.combine (@fields1 ) }, | |
"combine 10" => sub { $csv.combine (@fields10 ) }, | |
"combine 100" => sub { $csv.combine (@fields100) }, | |
"parse 1" => sub { $csv.parse ($str1 ) }, | |
"parse 10" => sub { $csv.parse ($str10 ) }, | |
"parse 100" => sub { $csv.parse ($str100 ) }, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment