fibonacci {RcppClock}R Documentation

Simple RcppClock example

Description

Time the computation of fibonacci numbers

Usage

fibonacci(n, reps = 10L)

Arguments

n

vector giving integers for which to compute the fibonacci sum

reps

number of replicates for timing

Details

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.

Examples

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")

[Package RcppClock version 1.1 Index]