Domain builder for automated benchmark collection across parameter spaces.
Provides functions for building domains by running benchmarks with varying inputs, plus input sequence generators for scaling analysis.
Domain builder for automated benchmark collection across parameter spaces. Provides functions for building domains by running benchmarks with varying inputs, plus input sequence generators for scaling analysis.
(domain-builder first-arg & args)Build a domain by running benchmarks across a parameter space.
Simplified form (no axes, just implementations): (domain-builder {:sort (measured/expr (sort coll)) :sort-by (measured/expr (sort-by identity coll))})
Full form with axes: (domain-builder {:n (log-range 10 10000 5)} {:sort (fn [{:keys [n]}] (measured/expr (sort (vec (range n)))))})
In the full form, implementations is a map of impl-key to measured-fn where each measured-fn is (fn [axis-map] measured) that receives the axis values and returns a Measured for that coordinate.
Options: :initial-limit-time-s - Time limit for runs before estimation kicks in (default: 10 seconds) :time-axis - Axis key for complexity modeling (default: first axis) :reporter - Progress reporter (default: dot-reporter, nil for silent) :bench-options - Additional options passed to bench-measured
Benchmarks run in order: all coordinates for first implementation, then all for second, etc. Within each implementation, coordinates are sorted by :time-axis ascending (smallest values first) to enable adaptive time estimation.
When a benchmark hits its time limit and the projected time differs from the limit by more than 5%, the benchmark is re-run with the projected time.
Returns a domain with runs indexed by {:impl impl-key ...axis-coords...}. When multiple implementations are provided, the domain's :impl-axis key is set to :impl, enabling automatic grouping in analysis functions.
Build a domain by running benchmarks across a parameter space.
Simplified form (no axes, just implementations):
(domain-builder {:sort (measured/expr (sort coll))
:sort-by (measured/expr (sort-by identity coll))})
Full form with axes:
(domain-builder {:n (log-range 10 10000 5)}
{:sort (fn [{:keys [n]}]
(measured/expr (sort (vec (range n)))))})
In the full form, implementations is a map of impl-key to measured-fn where
each measured-fn is (fn [axis-map] measured) that receives the axis values
and returns a Measured for that coordinate.
Options:
:initial-limit-time-s - Time limit for runs before estimation kicks in
(default: 10 seconds)
:time-axis - Axis key for complexity modeling
(default: first axis)
:reporter - Progress reporter
(default: dot-reporter, nil for silent)
:bench-options - Additional options passed to bench-measured
Benchmarks run in order: all coordinates for first implementation,
then all for second, etc. Within each implementation, coordinates are
sorted by :time-axis ascending (smallest values first) to enable
adaptive time estimation.
When a benchmark hits its time limit and the projected time differs from
the limit by more than 5%, the benchmark is re-run with the projected time.
Returns a domain with runs indexed by {:impl impl-key ...axis-coords...}.
When multiple implementations are provided, the domain's :impl-axis
key is set to :impl, enabling automatic grouping in analysis functions.Protocol for reporting domain-builder progress.
Protocol for reporting domain-builder progress.
(report-end reporter impl-key)Called when finished benchmarking an implementation.
Called when finished benchmarking an implementation.
(report-run reporter impl-key coord run-index)Called after completing a benchmark run.
Called after completing a benchmark run.
(report-start reporter impl-key total-runs)Called when starting to benchmark an implementation.
Called when starting to benchmark an implementation.
(dot-reporter)Create a dot reporter that prints progress dots.
Create a dot reporter that prints progress dots.
(linear-range start end n)Generate a linearly-spaced sequence of n values from start to end. Values are rounded to integers.
Produces evenly-spaced values, useful for detecting linear scaling or when uniform sampling across a range is needed.
Examples: (linear-range 100 500 5) ;=> (100 200 300 400 500) (linear-range 0 1000 5) ;=> (0 250 500 750 1000)
Generate a linearly-spaced sequence of n values from start to end. Values are rounded to integers. Produces evenly-spaced values, useful for detecting linear scaling or when uniform sampling across a range is needed. Examples: (linear-range 100 500 5) ;=> (100 200 300 400 500) (linear-range 0 1000 5) ;=> (0 250 500 750 1000)
(log-range start end n)Generate a logarithmically-spaced sequence of n values from start to end. Values are rounded to integers.
Produces values where the ratio between successive elements is constant, useful for covering a wide range of input sizes efficiently.
Examples: (log-range 1 1000 4) ;=> (1 10 100 1000) (log-range 10 10000 5) ;=> (10 56 316 1778 10000)
Generate a logarithmically-spaced sequence of n values from start to end. Values are rounded to integers. Produces values where the ratio between successive elements is constant, useful for covering a wide range of input sizes efficiently. Examples: (log-range 1 1000 4) ;=> (1 10 100 1000) (log-range 10 10000 5) ;=> (10 56 316 1778 10000)
(n-log-n-range start end n)Generate n values from start to end spaced along an n*log(n) curve. Values are rounded to integers.
Useful for testing algorithms with O(n log n) complexity where you want denser sampling at smaller sizes and sparser sampling at larger sizes.
Start must be >= e^-1 (approximately 0.368) where x*ln(x) has its minimum.
Examples: (n-log-n-range 10 10000 5) ;=> sequence of 5 values from 10 to 10000
Generate n values from start to end spaced along an n*log(n) curve. Values are rounded to integers. Useful for testing algorithms with O(n log n) complexity where you want denser sampling at smaller sizes and sparser sampling at larger sizes. Start must be >= e^-1 (approximately 0.368) where x*ln(x) has its minimum. Examples: (n-log-n-range 10 10000 5) ;=> sequence of 5 values from 10 to 10000
(powers-of base from to)Generate a sequence of powers of base. Returns (base^from base^(from+1) ... base^to) inclusive.
Useful for testing with specific base increments.
Examples: (powers-of 10 1 4) ;=> (10 100 1000 10000) (powers-of 3 0 4) ;=> (1 3 9 27 81)
Generate a sequence of powers of base. Returns (base^from base^(from+1) ... base^to) inclusive. Useful for testing with specific base increments. Examples: (powers-of 10 1 4) ;=> (10 100 1000 10000) (powers-of 3 0 4) ;=> (1 3 9 27 81)
(powers-of-2 from to)Generate a sequence of powers of 2. Returns (2^from 2^(from+1) ... 2^to) inclusive.
Useful for testing algorithms where input size doubling reveals O(n), O(n log n), O(n²) patterns clearly.
Examples: (powers-of-2 0 4) ;=> (1 2 4 8 16) (powers-of-2 4 8) ;=> (16 32 64 128 256)
Generate a sequence of powers of 2. Returns (2^from 2^(from+1) ... 2^to) inclusive. Useful for testing algorithms where input size doubling reveals O(n), O(n log n), O(n²) patterns clearly. Examples: (powers-of-2 0 4) ;=> (1 2 4 8 16) (powers-of-2 4 8) ;=> (16 32 64 128 256)
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |