R performance best practices including profiling, benchmarking, vctrs, and optimization strategies.
SkillScore100Maintained
Automatic
◆Coding pack
Last verified 8/8/2026
What it changes
Passed 22 of 22 test cases with the skill, and 19 of 22 without it.
Without skill86%
With skill100%
Checks it passed that the model alone missed
recommends profvis for identifying unknown bottlenecks across call stacks
recommends using vec_cast to enforce explicit and consistent double output types
recommends setting check to FALSE to allow comparisons when output structures slightly differ
3 fixed19 passed either way0 still failing0 broke
Pass-rate lift
+14 pp
Tokens
+116%
Agent turns
0%
Response time
-17%
Model gemini-3.6-flashMeasured 8/8/2026v122 of 22 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 3
Prompt
I have a complex script with multiple nested function calls taking 45 seconds, but I don't know which line or function is causing the slowdown. Should I benchmark individual helper functions right away or line-profile the entire execution block, and what tool should I use?
What was checked, without and with the skill
Checked
Without skill
With skill
recommends line profiling the full block before benchmarking specific functions
Passed
Passed
recommends profvis for identifying unknown bottlenecks across call stacks
Missed
Passed
case-01 · gemini-3.6-flash · 8/8/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md348 linessingle file
R Performance Best Practices
Profiling, benchmarking, and optimization strategies for R code
Performance Tool Selection Guide
When to Use Each Performance Tool
Profiling Tools Decision Matrix
Tool
Use When
Don't Use When
What It Shows
profvis
Complex code, unknown bottlenecks
Simple functions, known issues
Time per line, call stack
bench::mark()
Comparing alternatives
Single approach
Relative performance, memory
system.time()
Quick checks
Detailed analysis
Total runtime only
Rprof()
Base R only environments
When profvis available
Raw profiling data
Step-by-Step Performance Workflow
# 1. Profile first - find the actual bottlenecks
library(profvis)
profvis({
# Your slow code here
})
# 2. Focus on the slowest parts (80/20 rule)
# Don't optimize until you know where time is spent
# 3. Benchmark alternatives for hot spots
library(bench)
bench::mark(
current = current_approach(data),
vectorized = vectorized_approach(data),
parallel = map(data, in_parallel(func))
)
# 4. Consider tool trade-offs based on bottleneck type