matrix.ts

The shape every table of the results pages shares: rows of one entry per library, in groups. The modules that read a results file build these, and one component renders them, so throughput, cold start, bundle size, and output size are compared the same way.

An entry is a number or the reason there is none, and the reasons stay apart: unsupported (the library doesn't claim the language), excluded (it claims it and failed the output check), none (the library has no such thing, like a wasm binary), and unmeasured (the file holds no number here). Only a number ever enters a ratio or a geometric mean.

view source

Declarations
#

19 declarations

coverage_claims_lang
#

matrix.ts view source

(coverage: Record<string, Record<string, true | { via: string; }>>, library: string, lang: string): boolean import {coverage_claims_lang} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

Whether a library's coverage claims a language.

coverage

type Record<string, Record<string, BenchCoverageEntry>>

library

type string

lang

type string

returns

boolean

format_matrix_value
#

matrix.ts view source

(value: number, unit: MatrixUnit): string import {format_matrix_value} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

A row's number as text, in the row's unit.

value

type number

unit

returns

string

matrix_row_baseline
#

matrix.ts view source

(row: MatrixRow, libraries: readonly string[], reference: string | null): number | null import {matrix_row_baseline} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

The number a row's ratios are taken against: the reference library's, or the best among the libraries when no reference is chosen.

When any of the libraries' numbers can't be ranked (one that isn't positive, or one marked unranked), the best of the rest is never used: the number set aside may be the smallest in the row. A row with a resolution is then compared with that resolution, and a row without one has no baseline.

row

libraries

type readonly string[]

reference

a library id, or null for the best in the row

type string | null

returns

number | null

the baseline, or null when the row isn't compared, a number in it can't be ranked and the row has no resolution, the reference has no number, or no library has one

matrix_row_entry
#

matrix.ts view source

(row: MatrixRow, library: string): MatrixEntry import {matrix_row_entry} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

A library's entry in a row.

row

library

type string

returns

MatrixEntry

matrix_row_is_bounded
#

matrix.ts view source

(row: MatrixRow, libraries: readonly string[], reference: string | null): boolean import {matrix_row_is_bounded} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

Whether a row's ratios are lower bounds: its baseline is the row's resolution, because the smallest numbers in it are below what can be told apart. The true ratio to the best is at least the one shown.

row

libraries

type readonly string[]

reference

type string | null

returns

boolean

matrix_row_is_complete
#

matrix.ts view source

(row: MatrixRow, libraries: readonly string[]): boolean import {matrix_row_is_complete} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

Whether every one of the libraries has a number in the row that a ratio can be made from. Only such a row enters a geometric mean.

row

libraries

type readonly string[]

returns

boolean

matrix_row_value
#

matrix.ts view source

(row: MatrixRow, library: string): number | null import {matrix_row_value} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

A library's number in a row, or null when its entry is anything else.

row

library

type string

returns

number | null

matrix_rows_max
#

matrix.ts view source

(rows: readonly MatrixRow[], libraries: readonly string[]): number import {matrix_rows_max} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

The largest finite number of these libraries over these rows, which a full bar stands for: 0 when there is none.

rows

type readonly MatrixRow[]

libraries

type readonly string[]

returns

number

MatrixBadge
#

matrix.ts view source

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

A short mark on a value that a reader should weigh, with the reason.

text

type string

title

type string

MatrixEntry
#

matrix.ts view source

MatrixEntry

type MatrixValue | { kind: "unsupported"; langs: string[]; } | { kind: "excluded"; reason: string; } | { kind: "none"; text: string; } | { kind: "unmeasured"; }

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

One library's place in a row: a number, or why there is none.

MatrixGroup
#

matrix.ts view source

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

Rows under one heading.

key

type string

label

type string

note

type string | null

rows

type MatrixRow[]

MatrixResults
#

matrix.ts view source

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

A results file as the results pages receive it: without the corpus inputs.

langs

type BenchLang[]

startup

type BenchStartup[]

meta

type BenchMeta

sets

type BenchSet[]

cells

type BenchCell[]

bundle

type Record<string, Record<string, BenchBundleEntry>>

install

type Record<string, BenchInstall>

heap

type Record<string, Record<string, BenchHeap>>

coverage

type Record<string, Record<string, BenchCoverageEntry>>

MatrixRow
#

matrix.ts view source

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

One row of a table: a cell of the benchmark, or a summary over cells.

key

type string

kind

type "cell" | "summary"

label

type string

note

type string | null

unit

type MatrixUnit

direction

type RatioDirection

compared

Whether the row's numbers are compared: a row that is not has no ratios.

type boolean

floor

The noise floor the row's ratios are read against, as BenchNoiseFloor holds it, or null for a row with none: only a timed throughput row has one.

type number | null

resolution

The smallest difference the row can tell apart, in the row's unit, or null for a row whose numbers are all exact. When a number in the row is below it, the others are compared with it, as lower bounds. Only a cold-start row has one.

type number | null

entries

By library id. A library with no entry reads as unmeasured.

type Record<string, MatrixEntry>

empty

Set in place of entries when the row has nothing to show for any library.

type string | null

MatrixUnit
#

matrix.ts view source

MatrixUnit

type "bytes" | "ops_per_sec" | "mb_per_sec" | "ns" | "ms" | "count"

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

What a row's numbers are, which decides how they print.

MatrixValue
#

matrix.ts view source

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

A number in a row, with what a reader may want to know about it.

kind

type "value"

value

type number

text

Printed in place of the number, when the number itself would mislead.

type string | null

details

type string[]

badges

type MatrixBadge[]

unranked

Why the number can't be compared with another, or null when it can. Such a number has no ratio, and its row is left out of a geometric mean.

type string | null

to_geomean_row
#

matrix.ts view source

(rows: readonly MatrixRow[], libraries: readonly string[], key: string, label: string): MatrixRow | null import {to_geomean_row} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

A summary row holding each library's geometric mean over the rows that are complete for every one of the libraries. A mean over a different set of rows for each library would favor whichever library skipped the slow ones, so a row missing any selected library is left out for all of them, as is a row holding a number that can't be ranked, whose ratios are at best bounds, and the row's note says how many it covers. With no complete row there is no mean, and the row says so in place of its entries.

rows

the cell rows to summarize, sharing a unit and a direction

type readonly MatrixRow[]

libraries

the selected library ids

type readonly string[]

key

type string

label

type string

returns

MatrixRow | null

the summary row, or null when there are no rows to summarize

to_matrix_ratios
#

matrix.ts view source

(row: MatrixRow, libraries: readonly string[], reference: string | null): Record<string, number> import {to_matrix_ratios} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

Each library's ratio against the row's baseline: 1 is the baseline, and more is that many times worse. A number that can't be ranked has no ratio, nor has one under the resolution of a row whose ratios are bounds, and a row where fewer than two of the libraries have a number has none at all: there is nothing to compare.

row

libraries

type readonly string[]

reference

type string | null

returns

Record<string, number>

the ratios by library id, for the libraries that have one

to_matrix_row
#

matrix.ts view source

(row: Pick<MatrixRow, "label" | "key" | "unit" | "direction"> & Partial<MatrixRow>): MatrixRow import {to_matrix_row} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

A row with the defaults filled in.

row

type Pick<MatrixRow, "label" | "key" | "unit" | "direction"> & Partial<MatrixRow>

returns

MatrixRow

to_value_entry
#

matrix.ts view source

(value: number, options?: Partial<Omit<MatrixValue, "value" | "kind">>): MatrixValue import {to_value_entry} from '@ryanatkn/syntax-highlighter-bench/matrix.js';

An entry holding a number.

value

type number

options

type Partial<Omit<MatrixValue, "value" | "kind">>
default {}

returns

MatrixValue

Depends on
#

Imported by
#