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)

An immutable benchmark suite configuration builder.

pub type BenchmarkBuilder {
  BenchmarkBuilder(
    algorithms: List(Algorithm),
    cases: List(Case),
    iterations: Int,
  )
}

Constructors

  • BenchmarkBuilder(
      algorithms: List(Algorithm),
      cases: List(Case),
      iterations: Int,
    )

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,
    )

A benchmark test case containing two strings to compare.

pub type Case {
  Case(name: String, left: String, right: String)
}

Constructors

  • Case(name: String, left: String, right: String)

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.

Search Document