Skip to content
Browse files

Add fib.nqp as a recursion benchmark example.

  • Loading branch information...
1 parent df8c49d commit f59925ced7063e24384e7708a40384dc23e48221 @pmichaud pmichaud committed Sep 21, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 examples/fib.nqp
View
14 examples/fib.nqp
@@ -0,0 +1,14 @@
+#! nqp
+
+sub fib($n) {
+ $n < 2 ?? $n !! fib($n-1) + fib($n - 2);
+}
+
+my $N := 29;
+
+my $t0 := pir::time__N();
+my $z := fib($N);
+my $t1 := pir::time__N();
+
+pir::say("fib($N) = " ~ fib($N));
+pir::say("time = " ~ ($t1-$t0));

0 comments on commit f59925c

Please sign in to comment.
Something went wrong with that request. Please try again.