Skip to contents

Times an expression and measures change in memory allocation.

Usage

benchmark_resource_usage(expr)

Arguments

expr

Expression or function to benchmark.

Value

A list with elapsed seconds and peak memory allocated (MB).

Examples

benchmark_resource_usage({ Sys.sleep(0.01); 1 + 1 })
#> $result
#> [1] 2
#> 
#> $elapsed_seconds
#> [1] 0.01
#> 
#> $memory_mb
#> [1] 0.003652954
#>