Title: | 'Rcpp' Tic-Toc Timer with 'OpenMP' Support |
---|---|
Description: | Provides 'Rcpp' bindings for 'cpptimer', a simple tic-toc timer class for benchmarking 'C++' code <https://github.com/BerriJ/cpptimer>. It's not just simple, it's blazing fast! This sleek tic-toc timer class supports overlapping timers as well as 'OpenMP' parallelism <https://www.openmp.org/>. It boasts a nanosecond-level time resolution. We did not find any overhead of the timer itself at this resolution. Results (with summary statistics) are automatically passed back to 'R' as a data frame. |
Authors: | Jonathan Berrisch [aut, cre] |
Maintainer: | Jonathan Berrisch <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.2.1 |
Built: | 2024-11-22 06:27:11 UTC |
Source: | CRAN |
Time the computation of Fibonacci numbers
fibonacci(n)
fibonacci(n)
n |
vector giving integers for which to compute the Fibonacci sum |
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 = 15
is nearly unmeasurable.
vector of integers giving the Fibonacci sum for each element in
n
fibonacci(n = rep(20:25, 10)) # this function creates a global environment variable "times" times
fibonacci(n = rep(20:25, 10)) # this function creates a global environment variable "times" times
Time the multithreaded computation of Fibonacci numbers
fibonacci_omp(n)
fibonacci_omp(n)
n |
vector giving integers for which to compute the Fibonacci sum |
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 = 15
is nearly unmeasurable.
vector of integers giving the Fibonacci sum for each element in
n
fibonacci_omp(n = rep(20:25, 10)) # this function creates a global environment variable "times" times
fibonacci_omp(n = rep(20:25, 10)) # this function creates a global environment variable "times" times
Prints the times object and scales the timings if appropriate. If all timings are smaller than 1 microsecond, the timings are printed in nanoseconds. If the smallest timing is higher than a Millisecond / Seconds / Minutes / Hours, the timings are printed in the unit of that threshold. This behavior can be disabled by setting scale = FALSE.
## S3 method for class 'rcpptimer' print(x, scale = TRUE, ...)
## S3 method for class 'rcpptimer' print(x, scale = TRUE, ...)
x |
Object of class rcpptimer |
scale |
Scale the timings and statistics to a more human readable format |
... |
further arguments are ignored |