Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Add fib.nqp as a recursion benchmark example.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Sep 21, 2010
1 parent df8c49d commit f59925c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 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.