# Profvis

> R profvis package for interactive profiling. Use for visualizing R code profiling data.

- Skill: `leolin990405/profvis` (Agent Skill)
- Install (CLI): `npx get-skill add leolin990405/profvis`
- Raw SKILL.md: https://api.skillmd.com/api/skills/leolin990405/profvis/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: LeoLin990405 (https://skillmd.com/u/leolin990405)
- Updated: 2026-11-14
- Page: https://skillmd.com/skills/leolin990405/profvis

---


# profvis

Interactive visualizations for profiling R code.

## Basic Profiling

```r
library(profvis)

# Profile code block
profvis({
  # Code to profile
  data <- read.csv("large_file.csv")
  result <- lm(y ~ x, data = data)
  summary(result)
})
```

## Save Profile

```r
# Save to file
p <- profvis({
  # Code
})

# Save HTML
htmlwidgets::saveWidget(p, "profile.html")
```

## Profile Function

```r
# Profile a function
my_function <- function(n) {
  x <- rnorm(n)
  y <- x^2
  mean(y)
}

profvis({
  my_function(1e6)
})
```

## Interval

```r
# Adjust sampling interval (ms)
profvis({
  # Code
}, interval = 0.01)  # 10ms intervals
```

## Memory Profiling

```r
# Profile memory
profvis({
  x <- 1:1e7
  y <- x^2
  rm(x)
  gc()
})
```

## Flame Graph

```r
# View as flame graph
p <- profvis({
  # Code
})

# Interactive viewer shows:
# - Flame graph (call stack over time)
# - Data tab (detailed timing)
# - Source code highlighting
```

## With Shiny

```r
# Profile Shiny app
profvis({
  runApp("myapp", display.mode = "normal")
}, interval = 0.01)
```

## Pause Profiling

```r
profvis({
  # Profiled code
  pause(FALSE)  # Stop profiling
  # Not profiled
  pause(TRUE)   # Resume profiling
  # Profiled again
})
```

## Print Summary

```r
p <- profvis({
  # Code
})

# Print summary
print(p)
```

## Tips

```r
# 1. Use small interval for short code
profvis({ fast_code() }, interval = 0.005)

# 2. Run multiple times for stable results
profvis({
  for (i in 1:10) {
    my_function()
  }
})

# 3. Profile realistic workloads
```

