powered by
Time the computation of fibonacci numbers
fibonacci(n, reps = 10L)
vector giving integers for which to compute the fibonacci sum
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.
n = 25
# NOT RUN { 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") # }
Run the code above in your browser using DataLab