flix

0.81.0

Stats

Keeping the performance figures.

Pure arithmetic, so the awkward part -- a rolling average that has to start somewhere -- is testable without opening a window.

Type Aliases

type alias Sample = { clamped = Bool, drawNs = Int64, frameNs = Int64, simNs = Int64, steps = Int32 }§ Source

Single frame performance sample containing raw nanosecond metrics and step counts.

Definitions

def blend(first: Bool, previous: Float32, sample: Float32): Float32§ Source

A rolling average that does not have to crawl up from zero.

The first sample is taken whole. Blending it against an initial nought would show a frame rate climbing from 0 to 60 over the first second of every run, which looks like a stall and is really just the average filling up.

def empty(): Stats§ Source

Initial zeroed telemetry statistics record.

def millis(nanos: Int64): Float32§ Source

Converts a duration in nanoseconds to milliseconds as a Float32.

def observe(previous: Stats, sample: Sample): Stats§ Source

Folds one frame's measurements into the running figures.

def oneDecimal(value: Float32): String§ Source

A Float32 to one decimal place, without String.format.

Rounds rather than truncates, so 1.99 does not read as 1.9. Negatives are not expected -- these are durations and rates -- but they are handled rather than silently mangled.

def rateFrom(frameNs: Int64): Float32§ Source

The frame rate a gap of frameNs between frames implies.

A gap of nought or less means the clock has not moved, which happens on the first frame and on machines whose timer granularity is coarser than a frame. Reporting an infinity there would be arithmetically honest and useless to read.

def twoDecimals(value: Float32): String§ Source

A Float32 to two decimal places, for the sub-millisecond timings.

The simulation costs about 0.13ms. To one decimal that is 0.1, which cannot tell an improvement from a regression.