envzn
0.8 · beta · not released

Library / Date and time / Date and time / MeasuringTimer

CLASS

MeasuringTimer

A stack-scoped RAII elapsed-time probe.

Fields 3

int64 startNanos
String label
boolean reportOnExit

Constructors 2

INIT(REFERENCE String label)

Start a labelled timer.

INIT()

Start an unlabelled timer (reports under "timer").

Methods 5

METHOD elapsedNanos() RETURNS int64
reads

Elapsed monotonic nanoseconds since construction.

METHOD report() RETURNS String
reads

Human-readable elapsed time, auto-scaled to ns / us / ms / s, prefixed with the label: e.g. "parse phase: 1.234 ms".

METHOD show() RETURNS void
reads

Print the elapsed-time report line to stdout now. (Kept a normal method, not inlined into CLEANUP: the kernel's header-ordering scanner doesn't walk destructor bodies, so the Stdio dependency must surface from a scanned method to order EV_stdio.hpp ahead of this class.)

MODIFY METHOD silence() RETURNS void
modifies

Suppress the automatic CLEANUP print — use elapsedNanos()/report() to read the value yourself.

MODIFY METHOD unsilence() RETURNS void
modifies

Re-enable the automatic CLEANUP print.