gizlang:bench
benchmarks as data.
A suite declares its items (the rows of published tables), its tables (groups, with their method), its goals, and one function that measures the chosen items at a size. A suite program is Bench.main(sys, suite); that is its whole command line:
giz SUITE.giz list the items giz SUITE.giz run [ITEM...] [--size S] [--out FILE] giz SUITE.giz show the published results of the suite giz SUITE.giz compare [ITEM...] [--size S] a run beside the published values giz SUITE.giz record [ITEM...] a full run merged into the published file (a source checkout)
ITEM is an item id, with or without the suite id before it. S is quick (seconds), std (the default) or full (the size that was published). A run keeps what it measured item by item, so a stopped run is still of use.
A measure can run a program of any language: the program prints one line bench<TAB>ITEM<TAB>SUBJECT<TAB>VALUE for each value (report writes it), and program runs it and reads the lines (reported). A tool that is not on the machine skips its items with the way to get it (needs).
A published file (gizlang.bench.v1, results/AREA/NAME.json in the published results folder) is the one place a measurement is written: the site, the READMEs and compare read it. A row holds the value of each subject (Gizlang and the tools it is compared with), when and where it was measured, and whether a program wrote it (run) or it was moved in from a page by hand (migrated). text is shown instead of the number when a cell is not a single number.
import * as Bench from "gizlang:bench";Types
Subject
type Subject = { id: string; name: string; }A tool that a suite measures: Gizlang, or one it is compared with.
id:stringname:string
Item
type Item = { id: string; group: string; title: string; unit: string; better: string; }One row. group names the table that holds it ("" for the only table); better is "higher" or "lower".
id:stringgroup:stringtitle:stringunit:stringbetter:string
Value
type Value = { subject: string; value: f64; text: string; version: string; }The value of one subject in one row.
subject:stringvalue:f64text:stringversion:string
Measured
type Measured = { item: string; values: Vec<Value>; why: string; }The answer of a measure for one item: its values, or why it did not run.
item:stringvalues:Vec<gizlang_bench.Value>why:string
Suite
type Suite = { id: string; title: string; subjects: Vec<Subject>; groups: Vec<Group>; goals: Vec<Goal>; items: Vec<Item>; measure: (sys: System, items: Vec<Item>, size: string) => Vec<Measured>; }A suite: its tables, goals and items, and how to measure the chosen items. measure answers one Measured for each
item it was given; a subject that could not run has no value.
id:stringtitle:stringsubjects:Vec<gizlang_bench.Subject>groups:Vec<gizlang_bench.Group>goals:Vec<gizlang_bench.Goal>items:Vec<gizlang_bench.Item>measure:(sys: gizlang_system.System, items: Vec<gizlang_bench.Item>, size: string) => Vec<gizlang_bench.Measured>
Row
type Row = { item: Item; size: string; date: string; machine: string; build: string; source: string; note: string; values: Vec<Value>; }A measured row: the item, the size, when, where, with which build, and the values.
item:gizlang_bench.Itemsize:stringdate:stringmachine:stringbuild:stringsource:stringnote:stringvalues:Vec<gizlang_bench.Value>
Group
type Group = { id: string; title: string; method: string; }A table of rows: title names it and method says how it was measured (Markdown, one paragraph).
id:stringtitle:stringmethod:string
Goal
type Goal = { area: string; text: string; item: string; }A target: area names it, text states it, item (an item id, or "") says which row shows the progress.
area:stringtext:stringitem:string
Published
type Published = { suite: string; title: string; subjects: Vec<Subject>; groups: Vec<Group>; goals: Vec<Goal>; rows: Vec<Row>; }The published file of one suite.
suite:stringtitle:stringsubjects:Vec<gizlang_bench.Subject>groups:Vec<gizlang_bench.Group>goals:Vec<gizlang_bench.Goal>rows:Vec<gizlang_bench.Row>
Functions
ours
function ours(value: f64): ValueThe subject of Gizlang's own value.
of
function of (subject: string, value: f64): ValueThe value of another subject.
measured
function measured(item: Item, values: Vec<Value>): MeasuredThe values of ITEM.
skipped
function skipped(item: Item, why: string): MeasuredITEM did not run, for the reason WHY.
eachItem
function eachItem(sys: System, items: Vec<Item>, size: string, one: (sys: System, item: Item, size: string) => Result<Vec<Value>, string>): Vec<Measured>A measure of ITEMS that measures them one at a time with ONE.
Effects: fail, read, write, console, io.
needs
function needs(sys: System, name: string, how: string): string throws stringThe value of the environment variable NAME (a tool's path, a data folder), or why the items that need it skip:
HOW says how to get it.
Effects: fail, io.
wants
function wants(items: Vec<Item>, id: string): boolWhether ITEMS has the item ID.
Effects: fail.
report
function report(item: string, v: Value): voidPrints the line that tells a suite the value V of ITEM: bench<TAB>ITEM<TAB>SUBJECT<TAB>VALUE<TAB>TEXT<TAB>VERSION. A
program that a suite runs calls it once per value, beside its own output.
Effects: fail, console.
reported
function reported(items: Vec<Item>, out: Result<string, string>): Vec<Measured>The values that the lines of a program's output OUT report, as one Measured for each of ITEMS. When the program did not run (OUT is an error), every item skips with that reason.
Effects: fail.
suites
function suites(sys: System): stringThe folder that holds the suites (bench in a checkout); GIZLANG_BENCH_SUITES (set by giz bench) overrides it.
Effects: fail, io.
program
function program(sys: System, path: string, args: Vec<string>, environment: Vec<string>): string throws stringRuns the Gizlang program PATH (relative to the suites folder) with ARGS and the added ENVIRONMENT, shows what it prints, and answers its output, or why it failed.
Effects: fail, console, io.
cli
function cli(sys: System): stringThe command that runs Gizlang programs (giz); GIZLANG_CLI (set by giz bench) overrides it.
Effects: fail, io.
run
function run(sys: System, program: string, args: Vec<string>, environment: Vec<string>): string throws stringRuns the command PROGRAM with ARGS and the added ENVIRONMENT, shows what it prints (the report lines aside), and answers its output, or why it failed.
Effects: fail, console, io.
scaled
function scaled(size: string, quick: i64, std: i64, full: i64): i64A number that fits SIZE: QUICK for quick, FULL for full, STD otherwise.
nsPerCall
function nsPerCall(count: i64, work: (i: i64) => i64): f64Nanoseconds per call of WORK over COUNT calls. WORK answers a number; the numbers are summed so a call cannot be dropped as unused.
Effects: fail, read, write, console, io.
figures
function figures(value: f64): stringVALUE as a person reads it: three figures, no trailing zeros, thousands separated.
Effects: fail.
format
function format(value: f64, unit: string): stringVALUE with its UNIT: 302,589 req/s, 21 ms, 53%.
Effects: fail.
shown
function shown(v: Value, unit: string): stringWhat a cell shows: its text when it has one.
Effects: fail.
encode
function encode(p: Published): stringThe text of a published file (two-space indent, so a diff shows one row per change).
Effects: fail.
decode
function decode(text: string): Published throws stringThe published file in TEXT.
Effects: fail.
merged
function merged(base: Published, run: Published): PublishedBASE with the rows of RUN: a row of an item that RUN measured is replaced in its place, a new one is added at the end, the others stay. The title, subjects, groups and goals are RUN's: the suite program owns them.
Effects: fail.
machine
function machine(sys: System): stringThe machine a run is on, as a published row states it: AMD Ryzen 9 7945HX (32 threads), 64 GB, Linux 6.17.
Effects: fail, io.
published
function published(sys: System, dir: string, id: string): Published throws stringThe published file of the suite ID in DIR (the folder that holds AREA/NAME.json), if there is one.
Effects: fail, io.
main
function main(sys: System, suite: Suite): i64The command line of a suite program. Answers the exit status.
Effects: fail, read, write, console, io.
Methods
Row.value
function Row.value(self: Row, subject: string): Option<Value>The value of SUBJECT in the row, if the row has one.
Effects: fail.
Published.row
function Published.row(self: Published, id: string): Option<Row>The row of item ID, if P has one.
Effects: fail.
Published.name
function Published.name(self: Published, subject: string): stringThe name of SUBJECT in P.
Effects: fail.
Published.group
function Published.group(self: Published, id: string): GroupThe group ID of P (its title and method); an empty group when P has none of that id.
Effects: fail.
Constants
SCHEMA
const SCHEMA = "gizlang.bench.v1"The schema name that each published result file carries.