starfuzz/benchmark
A module providing performance benchmarking capabilities. Compares execution speeds of different similarity algorithms over a suite of test cases with target-independent millisecond timing.
Types
A named algorithm to be timed during the benchmark.
pub type Algorithm {
Algorithm(name: String, run: fn(String, String) -> Float)
}
Constructors
-
Algorithm(name: String, run: fn(String, String) -> Float)
The measured execution result of a single algorithm over a specific case.
pub type BenchmarkResult {
BenchmarkResult(
algorithm_name: String,
case_name: String,
iterations: Int,
elapsed_ms: Int,
)
}
Constructors
-
BenchmarkResult( algorithm_name: String, case_name: String, iterations: Int, elapsed_ms: Int, )
Values
pub fn add_algorithm(
builder: BenchmarkBuilder,
name: String,
run: fn(String, String) -> Float,
) -> BenchmarkBuilder
Adds a named similarity algorithm to the suite.
pub fn add_cases(
builder: BenchmarkBuilder,
cases: List(Case),
) -> BenchmarkBuilder
Adds a list of test cases to the suite.
pub fn new() -> BenchmarkBuilder
Creates a new BenchmarkBuilder with 1000 default iterations and no algorithms or cases.
pub fn now() -> Int
Returns the current system epoch time in milliseconds. Implemented via native Erlang and JavaScript FFI.
pub fn run(builder: BenchmarkBuilder) -> List(BenchmarkResult)
Runs the benchmark suite and returns the aggregated timing results.
pub fn with_iterations(
builder: BenchmarkBuilder,
iterations: Int,
) -> BenchmarkBuilder
Configures the number of iterations to execute for each test.