ratio.ts

Ratios between libraries and the one color scale every table of the site shares. A ratio is always "how many times worse than the baseline": 1 is the baseline itself, 2 is twice as slow or twice as large, and under 1 is better, which only happens against a chosen reference library.

view source

Declarations
#

12 declarations

ratio_is_within_floor
#

ratio.ts view source

(ratio: number, floor: number): boolean import {ratio_is_within_floor} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

Whether a ratio is inside a noise floor: the two numbers differ by no more than the machine shows between two measurements of the same library.

ratio

type number

floor

a deviation as BenchNoiseFloor holds it; 0.03 is 3%

type number

returns

boolean

RATIO_LEVEL_COLORS
#

ratio.ts view source

readonly string[] import {RATIO_LEVEL_COLORS} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The color of each level, as fuz_css variables that adapt to the color scheme: better than the reference, level with the baseline, then five steps worse, through yellow, orange, red, and brown to purple.

RATIO_LEVEL_LIMITS
#

ratio.ts view source

readonly number[] import {RATIO_LEVEL_LIMITS} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The ratios under which each level of the scale ends. A ratio at or past the last one is the last level. The scale reaches 100, since the libraries measured here are up to hundreds of times apart: a scale that stopped at a few times would color most of a table alike.

RatioDirection
#

ratio.ts view source

RatioDirection

type "lower" | "higher"

import type {RatioDirection} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

Whether a smaller or a larger number is the better one.

RatioLegendEntry
#

ratio.ts view source

RatioLegendEntry import type {RatioLegendEntry} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

One level of the color scale as a key shows it: its color and the ratios it covers.

color

type string

label

type string

note

What the level means, beyond its ratios, or null.

type string | null

to_bound_color
#

ratio.ts view source

(ratio: number): string import {to_bound_color} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The color of a ratio that is only a lower bound. A bound is taken against a row's resolution, not against the best in the row, so it is never given the color of a number level with the baseline, however close to 1 it is: a number that is at least the resolution is worse than one inside it.

ratio

type number

returns

string

to_geomean
#

ratio.ts view source

(values: readonly number[]): number | null import {to_geomean} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The geometric mean of positive numbers, or null for none.

values

type readonly number[]

returns

number | null

to_ratio
#

ratio.ts view source

(value: number, baseline: number, direction: RatioDirection): number | null import {to_ratio} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

How many times worse value is than baseline.

value

type number

baseline

type number

direction

returns

number | null

the ratio, or null when either number isn't positive and finite, so a ratio is never made from a zero

to_ratio_color
#

ratio.ts view source

(ratio: number): string import {to_ratio_color} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The color of a ratio. The tables tint a cell with it and always print the ratio too.

ratio

type number

returns

string

to_ratio_display_color
#

ratio.ts view source

(ratio: number, bound: boolean): string import {to_ratio_display_color} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The color of a ratio as shown: a lower bound's when bound, the scale's otherwise. Every table cell, table bar, and chart ratio is colored through it.

ratio

type number

bound

type boolean

returns

string

to_ratio_legend
#

ratio.ts view source

(): RatioLegendEntry[] import {to_ratio_legend} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The color scale as a key, level by level, from the limits it is drawn from, so the key can't disagree with the cells.

returns

RatioLegendEntry[]

to_ratio_level
#

ratio.ts view source

(ratio: number): number import {to_ratio_level} from '@ryanatkn/syntax-highlighter-bench/ratio.js';

The level of the color scale a ratio falls in, from 0 (better than the reference) to the last index of RATIO_LEVEL_COLORS. It never decreases as the ratio grows.

ratio

type number

returns

number

Imported by
#