Skip to content

Commit

Permalink
Convert most existing microbenchmarks to be auto-scaled, with a first…
Browse files Browse the repository at this point in the history
… guess at an appropriate starting scale for each
  • Loading branch information
japhb committed May 14, 2013
1 parent 71e806d commit da8fda3
Showing 1 changed file with 105 additions and 104 deletions.
209 changes: 105 additions & 104 deletions microbenchmarks.pl
Expand Up @@ -19,184 +19,185 @@
nqp => 'say("Hello, World!")',
},
{
name => 'while_empty_1e5',
perl5 => 'my $i = 0; while (++$i <= 100000) { }',
perl6 => 'my $i = 0; while (++$i <= 100000) { }',
nqp => 'my $i := 0; while ($i := $i + 1) <= 100000 { }',
name => 'while_empty',
scale => 1 << 13,
perl5 => 'my $i = 0; while (++$i <= SCALE) { }',
perl6 => 'my $i = 0; while (++$i <= SCALE) { }',
nqp => 'my $i := 0; while ($i := $i + 1) <= SCALE { }',
},
{
name => 'while_empty_1e6',
perl5 => 'my $i = 0; while (++$i <= 1000000) { }',
perl6 => 'my $i = 0; while (++$i <= 1000000) { }',
nqp => 'my $i := 0; while ($i := $i + 1) <= 1000000 { }',
},
{
name => 'while_bind_1e5',
name => 'while_bind',
scale => 1 << 16,
perl5 => undef,
perl6 => 'my $a := 0; my $b := 1; my $i = 0; while (++$i <= 100000) { $a := $b }',
nqp => 'my $a := 0; my $b := 1; my $i := 0; while ($i := $i + 1) <= 100000 { $a := $b }',
},
{
name => 'while_concat_1e5',
perl5 => 'my $s = ""; my $i = 0; while (++$i <= 100000) { $s .= "x" }',
perl6 => 'my $s = ""; my $i = 0; while (++$i <= 100000) { $s ~= "x" }',
nqp => 'my $s := ""; my $i := 0; while ($i := $i + 1) <= 100000 { $s := $s ~ "x" }',
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 }',
},
{
name => 'while_push_join_1e4',
perl5 => 'my @a; my $i = 0; while (++$i <= 10000) { push @a, "x" }; my $s = join "" => @a;',
perl6 => 'my @a; my $i = 0; while (++$i <= 10000) { @a.push("x") }; my $s; $s = @a.join;',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= 10000 { @a.push("x"); }; my $s := nqp::join("",@a);',
name => 'while_concat',
scale => 1 << 16,
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" }',
},
{
name => 'while_push_join_1e5',
perl5 => 'my @a; my $i = 0; while (++$i <= 100000) { push @a, "x" }; my $s = join "" => @a;',
perl6 => 'my @a; my $i = 0; while (++$i <= 100000) { @a.push("x") }; my $s; $s = @a.join;',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= 100000 { @a.push("x"); }; my $s := nqp::join("",@a);',
name => 'while_push_join',
scale => 1 << 13,
perl5 => 'my @a; my $i = 0; while (++$i <= SCALE) { push @a, "x" }; my $s = join "" => @a;',
perl6 => 'my @a; my $i = 0; while (++$i <= SCALE) { @a.push("x") }; my $s; $s = @a.join;',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= SCALE { @a.push("x"); }; my $s := nqp::join("",@a);',
},
{
name => 'while_push_1e4',
perl5 => 'my @a; my $i = 0; while (++$i <= 10000) { push @a, 1 }',
perl6 => 'my @a; my $i = 0; while (++$i <= 10000) { push @a, 1 }',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= 10000 { @a.push(1) }',
name => 'while_push',
scale => 1 << 13,
perl5 => 'my @a; my $i = 0; while (++$i <= SCALE) { push @a, 1 }',
perl6 => 'my @a; my $i = 0; while (++$i <= SCALE) { push @a, 1 }',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= SCALE { @a.push(1) }',
},
{
name => 'while_array_set_1e4',
perl5 => 'my @a; my $i = 0; while (++$i <= 10000) { $a[ $i ] = $i }',
perl6 => 'my @a; my $i = 0; while (++$i <= 10000) { @a[ $i ] = $i }',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= 10000 { @a[ $i ] := $i }',
name => 'while_array_set',
scale => 1 << 13,
perl5 => 'my @a; my $i = 0; while (++$i <= SCALE) { $a[ $i ] = $i }',
perl6 => 'my @a; my $i = 0; while (++$i <= SCALE) { @a[ $i ] = $i }',
nqp => 'my @a; my $i := 0; while ($i := $i + 1) <= SCALE { @a[ $i ] := $i }',
},
{
name => 'while_hash_set_1e4',
perl5 => 'my %h; my $i = 0; while (++$i <= 10000) { $h{ $i } = $i }',
perl6 => 'my %h; my $i = 0; while (++$i <= 10000) { %h{ $i } = $i }',
nqp => 'my %h; my $i := 0; while ($i := $i + 1) <= 10000 { %h{ $i } := $i }',
name => 'while_hash_set',
scale => 1 << 13,
perl5 => 'my %h; my $i = 0; while (++$i <= SCALE) { $h{ $i } = $i }',
perl6 => 'my %h; my $i = 0; while (++$i <= SCALE) { %h{ $i } = $i }',
nqp => 'my %h; my $i := 0; while ($i := $i + 1) <= SCALE { %h{ $i } := $i }',
},
{
name => 'postwhile_nil_1e5',
perl5 => 'my $i = -100000; () while ++$i;',
perl6 => 'my $i = -100000; Nil while ++$i;',
nqp => 'my $i := -100000; () while $i := $i + 1;',
name => 'postwhile_nil',
scale => 1 << 16,
perl5 => 'my $i = -SCALE; () while ++$i;',
perl6 => 'my $i = -SCALE; Nil while ++$i;',
nqp => 'my $i := -SCALE; () while $i := $i + 1;',
},
{
name => 'loop_empty_1e5',
perl5 => 'for (my $i = 1; $i <= 100000; ++$i) { }',
perl6 => 'loop (my $i = 1; $i <= 100000; ++$i) { }',
name => 'loop_empty',
scale => 1 << 16,
perl5 => 'for (my $i = 1; $i <= SCALE; ++$i) { }',
perl6 => 'loop (my $i = 1; $i <= SCALE; ++$i) { }',
nqp => undef,
},
{
name => 'for_empty_1e5',
perl5 => 'for (1 .. 100000) { }',
perl6 => 'for (1 .. 100000) { }',
name => 'for_empty',
scale => 1 << 16,
perl5 => 'for (1 .. SCALE) { }',
perl6 => 'for (1 .. SCALE) { }',
nqp => undef,
},
{
name => 'for_bind_1e5',
name => 'for_bind',
scale => 1 << 16,
perl5 => undef,
perl6 => 'my $a := 0; my $b := 1; for (1 .. 100000) { $a := $b; }',
perl6 => 'my $a := 0; my $b := 1; for (1 .. SCALE) { $a := $b; }',
nqp => undef,
},
{
name => 'for_assign_1e5',
perl5 => 'my $a = 0; my $b = 1; for (1 .. 100000) { $a = $b; }',
perl6 => 'my $a = 0; my $b = 1; for (1 .. 100000) { $a = $b; }',
name => 'for_assign',
scale => 1 << 16,
perl5 => 'my $a = 0; my $b = 1; for (1 .. SCALE) { $a = $b; }',
perl6 => 'my $a = 0; my $b = 1; for (1 .. SCALE) { $a = $b; }',
nqp => undef,
},
{
name => 'for_postinc_1e5',
perl5 => 'my $i = 0; for (1 .. 100000) { $i++ }',
perl6 => 'my $i = 0; for (1 .. 100000) { $i++ }',
name => 'for_postinc',
scale => 1 << 16,
perl5 => 'my $i = 0; for (1 .. SCALE) { $i++ }',
perl6 => 'my $i = 0; for (1 .. SCALE) { $i++ }',
nqp => undef,
},
{
name => 'for_concat_1e5',
perl5 => 'my $s = ""; for (1 .. 100000) { $s .= "x" }',
perl6 => 'my $s = ""; for (1 .. 100000) { $s ~= "x" }',
name => 'for_concat',
scale => 1 << 16,
perl5 => 'my $s = ""; for (1 .. SCALE) { $s .= "x" }',
perl6 => 'my $s = ""; for (1 .. SCALE) { $s ~= "x" }',
nqp => undef,
},
{
name => 'for_concat_2_1e5',
perl5 => 'my $x = "a"; my $y = ""; for (1 .. 100000) { $y .= ($x . $x) }',
perl6 => 'my $x = "a"; my $y = ""; for (1 .. 100000) { $y ~= ($x ~ $x) }',
name => 'for_concat_2',
scale => 1 << 16,
perl5 => 'my $x = "a"; my $y = ""; for (1 .. SCALE) { $y .= ($x . $x) }',
perl6 => 'my $x = "a"; my $y = ""; for (1 .. SCALE) { $y ~= ($x ~ $x) }',
nqp => undef,
},
{
name => 'for_push_1e4',
perl5 => 'my @a; for (1 .. 10000) { push @a, 1 }',
perl6 => 'my @a; for (1 .. 10000) { push @a, 1 }',
name => 'for_push',
scale => 1 << 13,
perl5 => 'my @a; for (1 .. SCALE) { push @a, 1 }',
perl6 => 'my @a; for (1 .. SCALE) { push @a, 1 }',
nqp => undef,
},
{
name => 'for_push_1e5',
skip => sub { shift->{compiler} eq 'rakudo' && !git_rev_ge('f6ee0c9b') },
perl5 => 'my @a; for (1 .. 100000) { push @a, 1 }',
perl6 => 'my @a; for (1 .. 100000) { push @a, 1 }',
name => 'for_array_set',
scale => 1 << 13,
perl5 => 'my @a; $a[ $_ ] = $_ for 1 .. SCALE',
perl6 => 'my @a; @a[ $_ ] = $_ for 1 .. SCALE',
nqp => undef,
},
{
name => 'for_array_set_1e4',
perl5 => 'my @a; $a[ $_ ] = $_ for 1 .. 10000',
perl6 => 'my @a; @a[ $_ ] = $_ for 1 .. 10000',
name => 'for_hash_set',
scale => 1 << 13,
perl5 => 'my %h; $h{ $_ } = $_ for 1 .. SCALE',
perl6 => 'my %h; %h{ $_ } = $_ for 1 .. SCALE',
nqp => undef,
},
{
name => 'for_hash_set_1e4',
perl5 => 'my %h; $h{ $_ } = $_ for 1 .. 10000',
perl6 => 'my %h; %h{ $_ } = $_ for 1 .. 10000',
name => 'reduce_range',
scale => 1 << 16,
perl5 => 'use List::Util "reduce"; reduce { $a + $b } 1 .. SCALE',
perl6 => '[+] 1 .. SCALE',
nqp => undef,
},
{
name => 'reduce_range_1e5',
perl5 => 'use List::Util "reduce"; reduce { $a + $b } 1 .. 100000',
perl6 => '[+] 1 .. 100000',
nqp => undef,
},
{
name => 'reduce_int_comb_range_1e4',
perl5 => 'use List::Util "reduce"; reduce { $a + $b } map { 0+$_ } map { split "" } 1 .. 10000',
perl6 => '[+] (1 .. 10000).comb>>.Int',
nqp => undef,
},
{
name => 'any_equals_1e3',
perl5 => undef,
perl6 => '1 == any(1 .. 1000)',
name => 'reduce_int_comb_range',
scale => 1 << 13,
perl5 => 'use List::Util "reduce"; reduce { $a + $b } map { 0+$_ } map { split "" } 1 .. SCALE',
perl6 => '[+] (1 .. SCALE).comb>>.Int',
nqp => undef,
},
{
name => 'any_equals_5e3',
name => 'any_equals',
scale => 1 << 10,
perl5 => undef,
perl6 => '1 == any(1 .. 5000)',
perl6 => '1 == any(1 .. SCALE)',
nqp => undef,
},
{
name => 'trim_string_1e3',
perl5 => 'my $s = " " x 1000 . "x" x 1000 . " " x 1000; /^\s*(.*?)\s*$/s for 1 .. 1000',
perl6 => 'my $s = " " x 1000 ~ "x" x 1000 ~ " " x 1000; $s.trim for 1 .. 1000',
name => 'trim_string',
scale => 1 << 10,
perl5 => 'my $s = " " x SCALE . "x" x SCALE . " " x SCALE; /^\s*(.*?)\s*$/s for 1 .. SCALE',
perl6 => 'my $s = " " x SCALE ~ "x" x SCALE ~ " " x SCALE; $s.trim for 1 .. SCALE',
nqp => undef,
},
{
name => 'visit_2d_indices_while',
perl5 => 'my $i = 0; while ($i < 100) { my $j = 0; while ($j < 100) { $i + $j; $j++ }; $i++ }',
perl6 => 'my $i = 0; while ($i < 100) { my $j = 0; while ($j < 100) { $i + $j; $j++ }; $i++ }',
nqp => 'my $i := 0; while ($i < 100) { my $j := 0; while ($j < 100) { $i + $j; $j := $j + 1 }; $i := $j + 1 }',
scale => 1 << 6,
perl5 => 'my $i = 0; while ($i < SCALE) { my $j = 0; while ($j < SCALE) { $i + $j; $j++ }; $i++ }',
perl6 => 'my $i = 0; while ($i < SCALE) { my $j = 0; while ($j < SCALE) { $i + $j; $j++ }; $i++ }',
nqp => 'my $i := 0; while ($i < SCALE) { my $j := 0; while ($j < SCALE) { $i + $j; $j := $j + 1 }; $i := $j + 1 }',
},
{
name => 'visit_2d_indices_loop',
perl5 => 'for (my $i = 0; $i < 100; $i++) { for (my $j = 0; $j < 100; $j++) { $i + $j } }',
perl6 => 'loop (my $i = 0; $i < 100; $i++) { loop (my $j = 0; $j < 100; $j++) { $i + $j } }',
scale => 1 << 6,
perl5 => 'for (my $i = 0; $i < SCALE; $i++) { for (my $j = 0; $j < SCALE; $j++) { $i + $j } }',
perl6 => 'loop (my $i = 0; $i < SCALE; $i++) { loop (my $j = 0; $j < SCALE; $j++) { $i + $j } }',
nqp => undef,
},
{
name => 'visit_2d_indices_for',
perl5 => 'for my $i (0 .. 99) { for my $j (0 .. 99) { $i + $j } }',
perl6 => 'for ^100 -> $i { for ^100 -> $j { $i + $j } }',
scale => 1 << 6,
perl5 => 'for my $i (0 .. (SCALE - 1)) { for my $j (0 .. (SCALE - 1)) { $i + $j } }',
perl6 => 'for ^SCALE -> $i { for ^SCALE -> $j { $i + $j } }',
nqp => undef,
},
{
name => 'visit_2d_indices_cross',
scale => 1 << 6,
perl5 => undef,
perl6 => 'for ^100 X ^100 -> $i, $j { $i + $j }',
perl6 => 'for ^SCALE X ^SCALE -> $i, $j { $i + $j }',
nqp => undef,
},
]

0 comments on commit da8fda3

Please sign in to comment.