Permalink
Browse files

[GH #837] New comparison benchmark against stress_stringsu.pir

Bad news:
There is almost no measurable speed advantage from ascii strings to encoded strings.
With the fix and without the fix, as sprintf handling slows down the test 4x times.

So converting a SREG and const to encoded STRING* will not gain much performance.
  • Loading branch information...
Reini Urban
Reini Urban committed Sep 20, 2012
1 parent e82482e commit 9c8159314dd2d26365653fbcd8627b0f8fbb0559
Showing with 47 additions and 0 deletions.
  1. +47 −0 examples/benchmarks/stress_strings1.pir
@@ -0,0 +1,47 @@
+# Copyright (C) 2010-2012, Parrot Foundation.
+
+=head1 NAME
+
+examples/benchmarks/stress_strings1.pir - comparison with stress_stringsu.pir
+
+=head1 SYNOPSIS
+
+ % time ./parrot examples/benchmarks/stress_strings1.pir
+ % time ./parrot examples/benchmarks/stress_stringsu.pir
+
+=head1 DESCRIPTION
+
+Create non-encoded strings, running through the imcc optimizer.
+Some of the strings are long-lived, most of them are short lived.
+
+=cut
+
+.sub 'main' :main
+ .local pmc rsa # array of long lived strings.
+ .local pmc args
+ .local int i
+
+ rsa = new ['ResizableStringArray']
+ args = new ['ResizablePMCArray']
+ i = 0
+ push args, i
+ loop:
+ $S0 = "c"
+ args[0] = i
+ sprintf $S1, "%d", args
+ $S2 = concat $S0, $S1
+ $I0 = i % 10 # every 10th string is longlived
+ if $I0 goto inc_i
+ push rsa, $S2
+ inc_i:
+ inc i
+ if i < 10000000 goto loop
+
+.end
+
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:

0 comments on commit 9c81593

Please sign in to comment.