benchmark-functions
Measure function performance and compare implementations. Use when optimizing critical code paths.
When & Why to Use This Skill
The benchmark-functions skill is a specialized performance analysis tool designed to systematically measure function execution time, memory usage, and computational efficiency. It empowers developers to make data-driven decisions by providing statistical insights and side-by-side comparisons of different code implementations, ensuring optimal performance in critical software paths.
Use Cases
- Algorithm Comparison: Evaluate and compare the execution speed and resource consumption of multiple algorithmic approaches to select the most efficient implementation.
- Optimization Impact Analysis: Quantify performance gains by measuring execution metrics before and after refactoring or applying optimization techniques.
- Performance Regression Testing: Establish baseline benchmarks for critical functions to detect and prevent performance degradation during the development lifecycle.
- Hardware & Implementation Profiling: Compare the efficiency of different implementation strategies, such as SIMD vs. scalar operations or Mojo vs. Python execution.
| name | benchmark-functions |
|---|---|
| description | "Measure function performance and compare implementations. Use when optimizing critical code paths." |
| mcp_fallback | none |
| category | analysis |
| tier | 2 |
| user-invocable | false |
Benchmark Functions
Systematically measure function execution time, memory usage, and performance characteristics to identify optimization opportunities.
When to Use
- Comparing different algorithm implementations
- Measuring performance before/after optimization
- Profiling SIMD vs scalar implementations
- Establishing performance baselines for CI/CD
Quick Reference
# Python benchmarking with timeit
python3 -m timeit -s 'import module' 'module.function(args)' -n 1000 -r 5
# Mojo benchmarking with built-in timing
mojo run benchmark_script.mojo
Workflow
- Set up benchmarks: Create timing harness with warm-up iterations
- Run measurements: Execute function multiple times, record timing
- Collect statistics: Calculate mean, median, std deviation
- Compare baselines: Compare against previous implementations
- Identify bottlenecks: Pinpoint functions needing optimization
Output Format
Benchmark report:
- Function name and parameters tested
- Execution time statistics (mean, median, min, max)
- Memory usage (if applicable)
- Comparison to baseline (improvement percentage)
- Iterations and sample size used
References
- See
profile-codeskill for detailed performance profiling - See
suggest-optimizationsskill for improvement strategies - See CLAUDE.md > Performance for Mojo optimization guidelines