Variable-Length-Input Benchmarks
This package provides a library to measure the running time of given procedure(s) for successively increasing input sizes and performing elementary statistical analysis on the resulting series.
1 Introduction
This package is currently a work-in-progress. Use with caution!
It is developed for helping with benchmarking and profiling the qi modular compiler.
2 Statistical Analysis
(require vlibench/private/statistics) | package: vlibench |
A simple module for performing statistical analysis on a set of results - durations - expected to have normal distribution.
struct
(struct stats (avg stdev min max count))
avg : real? stdev : real? min : real? max : real? count : positive-fixnum?
\bar{x}=\frac{1}{n}\sum_{i=1}^n x_i
\sigma(x)=\sqrt{\frac{1}{n}\sum_{i=1}^n (x_i-\bar{x})^2}
Returns the stats? struct containing the results.
procedure
(statistical-analysis raw-values [ #:max-sigma max-sigma])
→
(listof real?) stats? raw-values : (listof real?) max-sigma : real? = 3
Returns two values: the list of remaining samples that are taken into consideration when calculating the statistical analysis and the actual statistical analysis results.
3 Benchmarking
(require vlibench) | package: vlibench |
This module provides all procedures for setting the benchmarking up, running it and formatting results in a scribble document. It re-provides applicable bindings from the following private modules:
vlibench/profile-defaults ...
3.1 Profiles
(require vlibench/private/profile-struct) | |
package: vlibench |
This module defines a benchmarking profile.
struct
(struct vlib/profile (name mini mid maxi rep gc))
name : string? mini : fixnum? mid : (or/c fixnum? #f) maxi : fixnum? rep : fixnum? gc : (or/c 'never 'step 'always)
3.2 Benchmark Steps / Profile Input Sizes
(require vlibench/private/profile-steps) | package: vlibench |
3.3 Benchmark Structs
(require vlibench/private/benchmark-structs) | |
package: vlibench |
This module contains only the core structs for defininy and running benchmarks. Also, auxilliary syntaxes are provided to create those with source syntax included when applicable.
struct
(struct vlib/prog (label proc src))
label : string? proc : (-> any/c any) src : syntax?
Usually the procedure accepts a number or list of particular size as its argument. Such lists are created as part of the vlib/spec specification struct.
struct
(struct vlib/spec (name prepare progs))
name : string? prepare : (-> fixnum? any/c) progs : (listof vlib/prog?)
The preparation procedure is used to create an input value of desired length before actual benchmark is being run and measured.
struct
(struct vlib/result (len raw-times times stats))
len : fixnum? raw-times : (listof (listof positive-real?)) times : (listof (listof positive-real?)) stats : (listof stats?)
struct
(struct vli/benchark ( spec profile results duration fits rfit ratios)) spec : vlib/spec? profile : vlib/profile? results : (listof vlib/result) duration : positive-real? fits : (listof polynomial?) rfit : (list/c real? real?) ratios : (listof (listof real?))
3.4 Running Benchmarks
(require vlibench/private/benchmark-run) | package: vlibench |
This module provides the means of running the benchmark specification under given profile, producing the result.
3.5 Benchmark Utils
(require vlibench/private/benchmark-utils) | |
package: vlibench |
This module provides auxilliary procedures for constructing the benchmark specifications.
procedure
(make-random-integer-list len [max-test-int]) → (listof integer?)
len : fixnum? max-test-int : integer? = 1000000
4 Benchmark Reports
(require vlibench/private/report-snippets) | |
package: vlibench |
This module contains various scribble snippets allowing for simple creation of a comprehensive report about given benchmarks.
procedure
profile : vlib/profile? heading : block? = subsection
For example:
Profile: some name
Logarithmic/Linear Boundary: 10000
Number of measurements for each input length: 100
Garbage collection: never
procedure
(snippet:system-information [ heading #:more-versions more-versions #:more-generic more-generic]) → content? heading : block? = subsection more-versions : list? = '() more-generic : list? = '()
Detailed processor description is not available on Windows platform.
An example output is:
System Information
Racket Version: 8.16.0.1 - Welcome to Racket v8.16.0.1-2025-01-19-177ffc4ec9 [cs].
Operating System: linux
Architecture: x86_64
Runtime: chez-scheme
Machine: Linux f2a6543c6112 5.15.49-linuxkit #1 SMP Tue Sep 13 07:51:46 UTC 2022 x86_64
Processor Count: 16
Processor: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
procedure
(snippet:polynomial-formula fit [ max-rank epsilon]) → content? fit : polynomial? max-rank : fixnum? = 2 epsilon : real? = 1e-6
Program Name:
(lambda (lst) (for/sum ((v (in-list lst))) (* v v)))
\begin{alignat*}{5} \text{First Name:}\quad t & = & 2 & x^2 & + & & x & - & 5 \\ \text{Second Name:}\quad t & = & & x^2 & - & 3 & x & & \\ \end{alignat*}
A
B
C
A
1.0
2.0
5.0
B
0.5
1.0
2.5
C
0.2
0.4
1.0
procedure
(snippet:benchmark-ratio-fit benchmark [ nominator-label denominator-label]) → content? benchmark : vli/benchmark? nominator-label : string? = "Q" denominator-label : string? = "R"
\frac{Q}{R}=5x^{-1}+2
procedure
benchmark/s :
(or/c vli/benchmark? (listof vli/benchmark?))