R: Workout a group of expressions individually

workout {bench} | R Documentation

## Workout a group of expressions individually

### Description

Given an block of expressions in `{}` `workout()` individually times each expression in the group. `workout_expressions()` is a lower level function most useful when reading lists of calls from a file.

### Usage

    workout(expr, description = NULL)

    workout_expressions(exprs, env = parent.frame(), description = NULL)

### Arguments

`expr` | one or more expressions to workout, use `{}` to pass multiple expressions.
`description` | A name to label each expression, if not supplied the deparsed expression will be used.
`exprs` | A list of calls to measure.
`env` | The environment in which the expressions should be evaluated.

### Examples

    workout({
      x <- 1:1000
      evens <- x %% 2 == 0
      y <- x[evens]
      length(y)
      length(which(evens))
      sum(evens)
    })

    # The equivalent to the above, reading the code from a file
    workout_expressions(as.list(parse(system.file("examples/exprs.R", package = "bench"))))

[Package bench version 1.1.1 Index]