Added a simple sort benchmark #917

Closed
wants to merge 3 commits into
from
@@ -0,0 +1,48 @@
+# Copyright (C) 2013, Parrot Foundation.
+
+=head1 NAME
+
+examples/benchmarks/sort.pir - Sort an FixedIntegetArray of N integers
+
+=head1 SYNOPSIS
+
+ % time ./parrot examples/benchmarks/sort.pir
+
+=head1 DESCRIPTION
+
+Sorts an FixedIntegetArray of N random integers using builtin sort
+function for FixedIntegetArray. The argument N is specified from the
+command line.
+
+=cut
+
+.loadlib 'math_ops'
+
+.sub main :main
+ .param pmc argv
+ .local int N, i, j
+
+ N = argv[1]
+ $P0 = new ['FixedIntegerArray'], N
+ i = 0
+ j = 0
+
+LOOP:
+ j = rand 0, N
+ $P0[i] = j
+ inc i
+ if i < N goto LOOP
+
+ $P0.'sort'()
+
+.end
+
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+