fibonacci | R Documentation |
Time the computation of fibonacci numbers
fibonacci(n, reps = 10L)
n |
vector giving integers for which to compute the fibonacci sum |
reps |
number of replicates for timing |
The function being timed is the following:
int fib(int n) { return ((n <= 1) ? n : fib(n - 1) + fib(n - 2)); }
Runtime for computations less than n = 25
is nearly unmeasurable.
fibonacci(n = c(25:35), reps = 10) # this function creates a global environment variable "clock" # that is an S3 RcppClock object clock plot(clock) summary(clock, units = "ms")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.