Skip to content

Commit

Permalink
Start adding output and expected routines to microbenchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Broadwell committed Nov 10, 2014
1 parent 65539f1 commit 1122f8b
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions microbenchmarks.pl
Expand Up @@ -3,20 +3,23 @@
{
name => 'empty',
summarize => 0,
expected => '',
perl5 => '',
perl6 => '',
nqp => '',
},
{
name => 'zero',
summarize => 0,
expected => '',
perl5 => '0',
perl6 => '0',
nqp => '0',
},
{
name => 'hello',
summarize => 0,
expected => "Hello, World!\n",
perl5 => 'say "Hello, World!"',
perl6 => 'say "Hello, World!"',
nqp => 'say("Hello, World!")',
Expand All @@ -26,58 +29,65 @@
tags => [qw( while )],
scale => 1 << 10,
summarize => 0,
perl5 => 'my $i = 0; while (++$i <= SCALE) { }',
perl6 => 'my $i = 0; while (++$i <= SCALE) { }',
nqp => 'my $i := 0; while ($i := $i + 1) <= SCALE { }',
expected => sub { ($_[0] + 1) . "\n" },
perl5 => 'my $i = 0; while (++$i <= SCALE) { }; say $i;',
perl6 => 'my $i = 0; while (++$i <= SCALE) { }; say $i;',
nqp => 'my $i := 0; while ($i := $i + 1) <= SCALE { }; say($i);',
},
{
name => 'while_empty_native',
tags => [qw( while native )],
scale => 1 << 10,
summarize => 0,
perl5 => 'use integer; my $i = 0; while (++$i <= SCALE) { }',
perl6 => 'my int $i = 0; while ($i = $i + 1) <= SCALE { }',
nqp => 'my int $i := 0; while ($i := $i + 1) <= SCALE { }',
expected => sub { ($_[0] + 1) . "\n" },
perl5 => 'use integer; my $i = 0; while (++$i <= SCALE) { }; say $i;',
perl6 => 'my int $i = 0; while ($i = $i + 1) <= SCALE { }; say $i;',
nqp => 'my int $i := 0; while ($i := $i + 1) <= SCALE { }; say($i);',
},
{
name => 'while_bind',
tags => [qw( while bind )],
scale => 1 << 10,
perl5 => 'use Data::Alias; alias my $a = 0; alias my $b = 1; my $i = 0; while (++$i <= SCALE) { alias $a = $b }',
perl6 => 'my $a := 0; my $b := 1; my $i = 0; while (++$i <= SCALE) { $a := $b }',
nqp => 'my $a := 0; my $b := 1; my $i := 0; while ($i := $i + 1) <= SCALE { $a := $b }',
expected => sub { $_[0] ? "1\n" : "0\n" },
perl5 => 'use Data::Alias; alias my $a = 0; alias my $b = 1; my $i = 0; while (++$i <= SCALE) { alias $a = $b }; say $a;',
perl6 => 'my $a := 0; my $b := 1; my $i = 0; while (++$i <= SCALE) { $a := $b }; say $a;',
nqp => 'my $a := 0; my $b := 1; my $i := 0; while ($i := $i + 1) <= SCALE { $a := $b }; say($a);',
},
{
name => 'while_concat',
tags => [qw( while string )],
scale => 1 << 10,
perl5 => 'my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= "x" }',
perl6 => 'my $s = ""; my $i = 0; while (++$i <= SCALE) { $s ~= "x" }',
nqp => 'my $s := ""; my $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ "x" }',
expected => sub { $_[0] . "\n" },
perl5 => 'my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= "x" }; say length($s);',
perl6 => 'my $s = ""; my $i = 0; while (++$i <= SCALE) { $s ~= "x" }; say $s.chars;',
nqp => 'my $s := ""; my $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ "x" }; say(nqp::chars($s));',
},
{
name => 'while_concat_native',
tags => [qw( while string native )],
scale => 1 << 10,
perl5 => 'use integer; my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= "x" }',
perl6 => 'my str $s = ""; my int $i = 0; while ($i = $i + 1) <= SCALE { $s = $s ~ "x" }',
nqp => 'my str $s := ""; my int $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ "x" }',
expected => sub { $_[0] . "\n" },
perl5 => 'use integer; my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= "x" }; say length($s);',
perl6 => 'my str $s = ""; my int $i = 0; while ($i = $i + 1) <= SCALE { $s = $s ~ "x" }; say $s.chars;',
nqp => 'my str $s := ""; my int $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ "x" }; say(nqp::chars($s));',
},
{
name => 'while_int2str',
tags => [qw( while string int2str )],
scale => 1 << 10,
perl5 => 'my $i = 0; while (++$i <= SCALE) { my $s = "$i" }',
perl6 => 'my $i = 0; while (++$i <= SCALE) { my $s = ~$i }',
nqp => 'my $i := 0; while ($i := $i + 1) <= SCALE { my $s := ~$i }',
expected => sub { $_[0] . "\n" },
perl5 => 'my $i = 0; my $s = "$i"; while (++$i <= SCALE) { $s = "$i" }; say $s;',
perl6 => 'my $i = 0; my $s = ~$i; while (++$i <= SCALE) { $s = ~$i }; say $s;',
nqp => 'my $i := 0; my $s := ~$i; while ($i := $i + 1) <= SCALE { $s := ~$i }; say($s);',
},
{
name => 'while_int2str_native',
tags => [qw( while string int2str native )],
scale => 1 << 10,
perl5 => 'use integer; my $i = 0; while (++$i <= SCALE) { my $s = "$i" }',
perl6 => 'my int $i = 0; while ($i = $i + 1) <= SCALE { my str $s = ~$i }',
nqp => 'my int $i := 0; while ($i := $i + 1) <= SCALE { my str $s := ~$i }',
expected => sub { $_[0] . "\n" },
perl5 => 'use integer; my $i = 0; my $s = "$i"; while (++$i <= SCALE) { $s = "$i" }; say $s;',
perl6 => 'my int $i = 0; my str $s = ~$i; while ($i = $i + 1) <= SCALE { $s = ~$i }; say $s;',
nqp => 'my int $i := 0; my str $s := ~$i; while ($i := $i + 1) <= SCALE { $s := ~$i }; say($s);',
},
{
name => 'while_int2str_concat',
Expand Down

0 comments on commit 1122f8b

Please sign in to comment.