Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Bench Namespace Reference

Classes

struct  Bench_Result
 Outcome of one measured anchor benchmark. More...
 

Functions

std::string compiler_string ()
 Describe the compiler that produced the running binary.
 
std::string cpu_string ()
 Read the CPU model name advertised by the host.
 
std::size_t resolve_repeats (const std::size_t fallback)
 Resolve the number of timed repetitions for one anchor.
 
template<typename Work >
Bench_Result measure (std::string name, const double processed_cells, std::size_t repeats, Work &&work)
 Time a kernel with one warmup pass plus a median of timed passes.
 
void emit_json (const Bench_Result &result, std::ostream &out=std::cout)
 Print one benchmark result as a single structured JSON object.
 

Function Documentation

◆ compiler_string()

std::string Aleph::CA::Bench::compiler_string ( )
inline

Describe the compiler that produced the running binary.

Returns
a short vendor-and-version string such as "gcc 13.2.0".

Definition at line 80 of file bench_support.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by emit_json().

◆ cpu_string()

std::string Aleph::CA::Bench::cpu_string ( )
inline

Read the CPU model name advertised by the host.

On Linux the first model name line of /proc/cpuinfo is returned; any other platform (or a missing file) yields "unknown".

Returns
the CPU model string, sanitised of embedded commas and quotes so it is safe to splice into the JSON line.

Definition at line 100 of file bench_support.H.

References Aleph::and, and Aleph::blossom_maximum_cardinality_matching().

Referenced by emit_json(), and TEST().

◆ emit_json()

void Aleph::CA::Bench::emit_json ( const Bench_Result &  result,
std::ostream &  out = std::cout 
)
inline

Print one benchmark result as a single structured JSON object.

The schema is fixed at {name, wall_ns, cells_per_sec, compiler, cpu} so that perf_gate.py can parse the line with a plain JSON reader. The number fields use decimal (non-exponential) notation for maximum parser compatibility.

Parameters
resultthe benchmark to serialise.
outdestination stream (defaults to standard output).

Definition at line 199 of file bench_support.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Bench::Bench_Result::cells_per_sec, compiler_string(), cpu_string(), emit_json(), Aleph::CA::Bench::Bench_Result::name, out, and Aleph::CA::Bench::Bench_Result::wall_ns.

Referenced by emit_json(), and main().

◆ measure()

template<typename Work >
Bench_Result Aleph::CA::Bench::measure ( std::string  name,
const double  processed_cells,
std::size_t  repeats,
Work &&  work 
)

Time a kernel with one warmup pass plus a median of timed passes.

The callable is invoked repeats + 1 times. The first invocation is an untimed warmup that pages in memory and primes caches; the remaining invocations are timed with a steady clock and their median is reported. A fresh run on every invocation is the caller's responsibility, so engines that mutate state should be constructed inside work.

Template Parameters
Worknullary callable performing exactly one run.
Parameters
namestable benchmark identifier echoed into the JSON line.
processed_cellsnumber of cell updates performed by one run; used to derive the throughput figure.
repeatsnumber of timed passes (clamped to at least one).
workthe kernel under test.
Returns
the populated benchmark result.

Definition at line 156 of file bench_support.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Bench::Bench_Result::cells_per_sec, Aleph::count(), Aleph::median(), Aleph::CA::Bench::Bench_Result::name, and Aleph::CA::Bench::Bench_Result::wall_ns.

Referenced by main().

◆ resolve_repeats()

std::size_t Aleph::CA::Bench::resolve_repeats ( const std::size_t  fallback)
inline

Resolve the number of timed repetitions for one anchor.

The environment variable CA_BENCH_REPEATS, when set to a positive integer, overrides the per-benchmark default. This lets the orchestrator trade stability for wall time on slow runners without recompiling.

Parameters
fallbackdefault count used when the variable is unset or invalid.
Returns
the effective repetition count (always at least one).

Definition at line 128 of file bench_support.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by main().