Skip to content
Back to skills

Bench

ASecurity

R bench package for benchmarking. Use for high precision timing of R expressions.

  • 5 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 4, 2026
dataexpressperformance

Security analysis

A100/100

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill bench --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bench?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bench
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-bench/badge)](https://www.skillsdirectory.com/skills/leolin990405-bench)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bench
description: R bench package for benchmarking. Use for high precision timing of R expressions.
---

# bench

High precision timing of R expressions.

## Basic Benchmark

```r
library(bench)

# Time single expression
bench::mark(
  sqrt(1:1000)
)

# Compare expressions
bench::mark(
  sqrt = sqrt(1:1000),
  exp = exp(1:1000),
  log = log(1:1000)
)
```

## Options

```r
bench::mark(
  sqrt(x),
  exp(x),
  iterations = 100,      # Number of iterations
  check = TRUE,          # Check results are equal
  memory = TRUE,         # Track memory
  time_unit = "ms"       # Time unit
)
```

## Press (Parameter Grid)

```r
# Benchmark across parameters
results <- bench::press(
  n = c(100, 1000, 10000),
  {
    x <- runif(n)
    bench::mark(
      sort(x),
      order(x)
    )
  }
)

# Plot
autoplot(results)
```

## Results

```r
results <- bench::mark(
  sqrt(x),
  exp(x)
)

# Access columns
results$expression
results$min
results$median
results$mem_alloc
results$n_itr
results$n_gc
```

## Memory Tracking

```r
results <- bench::mark(
  method1 = { ... },
  method2 = { ... },
  memory = TRUE
)

# Memory allocated
results$mem_alloc
```

## Plotting

```r
library(ggplot2)

# Autoplot
autoplot(results)

# Custom plot
ggplot(results, aes(x = expression, y = median)) +
  geom_col()
```

## System Time

```r
# Measure system time
bench::system_time({
  # Code to time
  Sys.sleep(1)
})
```

## Garbage Collection

```r
# Force GC between iterations
bench::mark(
  expr,
  gc = TRUE
)

# Track GC
results$n_gc  # Number of GC runs
```

## Relative Performance

```r
# Compare relative to baseline
results <- bench::mark(
  baseline = method1(),
  improved = method2()
)

# Relative times
results$median / min(results$median)
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.