Permalink
Browse files

added a simple sort benchmark

  • Loading branch information...
mrshu committed Jan 6, 2013
1 parent f8d3536 commit eaecde7db19ba3fcfd640d77f73d3c5180a68f15
Showing with 47 additions and 0 deletions.
  1. +47 −0 examples/benchmarks/sort.pir
@@ -0,0 +1,47 @@
+# Copyright (C) 2013, Parrot Foundation.
+
+=head1 NAME
+
+examples/benchmarks/sort.pir - Sort an FixedIntegetArray of 10000 integers
+
+=head1 SYNOPSIS
+
+ % time ./parrot examples/benchmarks/sort.pir
+
+=head1 DESCRIPTION
+
+Sorts an FixedIntegetArray of 10000 random integers using builtin sort
+function for FixedIntegetArray
+
+=cut
+
+.loadlib 'math_ops'
+
+.sub main :main
+
+ .local int N, i, j
+
+ N = 10000
+ $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:
+

0 comments on commit eaecde7

Please sign in to comment.