memtime: memtime

Description Usage Arguments Value Author(s) Examples

Description

Compute time and memory usage of R code. WARNING: since memory usage is measured using free, it includes all running process (even background processes which are not relevant to the R code, expr). Memory usage numbers are only interpretable for your R code when there is constant background process activity on your entire system!

Usage

1
2
3
memtime(expr, gcFirst = TRUE, 
    free.file = tempfile(), 
    sleep.seconds = 1)

Arguments

expr

R code.

gcFirst

Run gc before computing initial time/memory values?

free.file

file where free output will be written.

sleep.seconds

Seconds to wait before/after calling free.profile.start/stop.

Value

List of time and memory usage.

Author(s)

Toby Dylan Hocking

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(memtime)
## Example: mclapply uses more memory than lapply! (compare
## max.increase rows)
library(parallel)
N <- 10000
memtime({
  mclapply(1:N, function(i)NULL, mc.cores=2)
})
memtime({
  lapply(1:N, function(i)NULL)
})

tdhock/memtime documentation built on Sept. 24, 2020, 5:05 a.m.