Skip to content

v3.bench

fn new #

fn new() Bench

new creates a new value for bench.

struct Bench #

struct Bench {
mut:
	steps                 []Step
	metrics               []Metric
	total_sw              time.StopWatch
	step_sw               time.StopWatch
	last_allocation_count u64
	last_allocated_bytes  u64
	memory_limit_kb       i64
	quiet                 bool
}

Bench represents bench data used by bench.

fn (Bench) disable_memory_limit #

fn (mut b Bench) disable_memory_limit()

disable_memory_limit disables the compiler memory safety limit.

fn (Bench) set_quiet #

fn (mut b Bench) set_quiet()

set_quiet suppresses benchmark output while retaining timing and memory checks.

fn (Bench) start_memory_monitor #

fn (b &Bench) start_memory_monitor()

start_memory_monitor starts the compiler memory safety watchdog.

fn (Bench) step #

fn (mut b Bench) step(name string)

step records a serial pipeline step.

fn (Bench) current_step_time_us #

fn (b &Bench) current_step_time_us() i64

current_step_time_us returns the elapsed wall time in the current pipeline step.

fn (Bench) step_measured #

fn (mut b Bench) step_measured(name string, elapsed_us i64)

step_measured records a pipeline step whose duration was accumulated externally, inside the wall time of the surrounding steps (used for work interleaved with another stage, e.g. the ownership checker inside check). It does not restart the step stopwatch, so the enclosing stages still account for their full wall time.

fn (Bench) step_parallel #

fn (mut b Bench) step_parallel(name string, parallel bool)

step_parallel records a pipeline step, appending "(parallel)" to its name when the step actually ran across threads.

fn (Bench) step_parts #

fn (mut b Bench) step_parts(parts []StepPart)

step_parts records measured parts that together make up the current pipeline step.

fn (Bench) metric #

fn (mut b Bench) metric(name string, value i64, unit string)

metric records a structural compiler counter for the final benchmark report.

fn (Bench) metric_items #

fn (b &Bench) metric_items(name string, value i64, unit string, items_label string, items []string)

metric_items prints a structural counter and a one-line list of its items immediately.

fn (Bench) print_report #

fn (b &Bench) print_report()

print_report updates print report state for Bench.

struct Metric #

struct Metric {
pub:
	name  string
	value i64
	unit  string
}

Metric represents one structural compiler counter reported with a build.

struct Step #

struct Step {
pub:
	name             string
	time_us          i64
	ram_kb           i64
	peak_ram_kb      i64
	allocation_count u64
	allocated_bytes  u64
}

Step represents step data used by bench.

struct StepPart #

struct StepPart {
pub:
	name     string
	time_us  i64
	parallel bool
}

StepPart describes one measured part of a pipeline step.