Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/fib.p6 Secret

Created April 21, 2014 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnthn/c739b869378133ccb09d to your computer and use it in GitHub Desktop.
Save jnthn/c739b869378133ccb09d to your computer and use it in GitHub Desktop.
sub fib($n) {
$n <= 1 ?? 1 !! fib($n - 2) + fib($n - 1)
}
for 1..10 -> $degree {
my $start = now;
my @fibs = await (start { fib(25) }) xx $degree;
say "$degree: {now - $start}";
die "Oops!" unless [==] @fibs;
}
1: 1.0476326 # baseline cost
2: 1.1106408
3: 1.2746614
4: 1.30716571 # number of physical cores
5: 1.4821886
6: 1.6322063
7: 1.6427082
8: 1.9857531 # number of virtual cores
9: 3.262914
10: 3.3859285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment