Line

You are reading the unreleased docs (next). See latest (v0.9)

packages/core/timing

Cheap wall-clock timing helpers shared by every generation/scaffolding command's console output -- process.hrtime.bigint() deltas, no new dependency.

Core engine, next. Source: packages/core/timing.mjs.

Functions#

elapsedSeconds()#

elapsedSeconds(start): number

Defined in: packages/core/timing.mjs:31

Elapsed seconds since start (a startTimer() value), as a plain number -- kept unformatted so a caller can still sum/compare several steps (e.g. a running total across a vertical slice or an import plan) before formatting the final number once.

Parameters#

start

bigint

A value from startTimer().

Returns#

number

Seconds elapsed since start, unformatted.


formatDuration()#

formatDuration(seconds): string

Defined in: packages/core/timing.mjs:47

Render a seconds value the way every timing line in this codebase shows it: two decimal places, an "s" suffix (e.g. "0.02s", "8.34s") -- matches how a human reads "how long did this take" without implying more precision than wall-clock timing actually has.

Parameters#

seconds

number

Duration in seconds.

Returns#

string

Seconds with two decimals and an s suffix.

Example#

formatDuration(8.3412); // => '8.34s'

startTimer()#

startTimer(): bigint

Defined in: packages/core/timing.mjs:18

Start a wall-clock timer.

Returns#

bigint

An opaque start value for elapsedSeconds.

Example#

const t = startTimer();
doWork();
formatDuration(elapsedSeconds(t)); // => "0.02s"