criterium

Benchmark Clojure code with statistically robust timing accounting for JIT warmup and GC.

1.2k|53|Updated Dec 16, 2009
One-click install
npx skills add https://github.com/hugoduncan/criterium --skill criterium
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: criterium
Source: https://github.com/hugoduncan/criterium/tree/main/skills/criterium
Command: npx skills add https://github.com/hugoduncan/criterium --skill criterium

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Benchmarking Clojure code can be unreliable without accounting for JVM warmup, garbage collection, and measurement overhead. Criterium provides a principled approach to obtaining stable timing data and meaningful statistics.

Core Features & Use Cases

  • Three-stage pipeline: Collection, Analysis, and View separate timing data gathering, processing, and presentation.
  • JVM-aware measurement: Handles warmup and GC to reduce timing noise.
  • Multiple bench plans and viewers: Supports distribution analysis, histograms, and various output formats for human or programmatic consumption.
  • Domain benchmarking and argument generation: Enables parameterized benchmarks across ranges and test-check generators for robust testing.
  • Real-world use: compare two implementations, analyze performance across input sizes, or tune code using measured results.

Quick Start

Install the library, load the bench namespace, and run a simple benchmark to observe timing results.

Frequently Asked Questions about criterium

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I benchmark Clojure code accurately without JIT warmup or GC skewing results?

To benchmark Clojure code accurately, you need a tool that accounts for JVM warmup, garbage collection, and measurement overhead. Criterium uses a three-stage pipeline—collection, analysis, and view—to produce statistically robust, repeatable timing data.

What is the best way to compare performance across different Clojure implementations?

Comparing Clojure implementations requires statistically robust timing that handles warmup and GC. Criterium enables comparative analysis through multiple bench plans and viewers, allowing you to measure and contrast execution times reliably across different code paths.

How do I run parameterized benchmarks across varying input sizes in Clojure?

You can run parameterized benchmarks in Clojure using domain benchmarking and argument generation. Criterium supports arg-gen and test-check generators to execute bench plans across specified input ranges, yielding performance analysis for each parameter.

Does Criterium require specific knowledge of its API to start performance tuning?

Yes, effective performance tuning with Criterium requires knowledge of its API, specifically the bench macro, bench plans, and arg-gen. This understanding allows you to leverage its three-stage pipeline for meaningful statistical analysis during code profiling.

Can I visualize benchmark distribution data and histograms for Clojure profiling?

You can visualize Clojure profiling data using various viewers in Criterium. The tool's view stage supports distribution analysis and histograms, presenting the processed timing data from the bench plans in formats suitable for human or programmatic consumption.

Why are my Clojure benchmark timings unstable and how do I get repeatable measurements?

Clojure benchmark timings are often unstable due to JVM warmup, garbage collection, and measurement overhead. Criterium addresses this by applying a principled approach to timing data gathering, ensuring stable measurements and meaningful statistics for performance tuning.