ostia 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -30
- package/docs/agent-protocol.md +13 -9
- package/docs/cli.md +174 -126
- package/docs/config.md +2 -2
- package/docs/document-schema.md +15 -12
- package/docs/library.md +32 -21
- package/docs/preload-recipes.md +4 -4
- package/docs/statistics.md +14 -13
- package/index.d.ts +202 -60
- package/package.json +1 -1
- package/src/ab/ab-runner.ts +6 -6
- package/src/ab/index.ts +56 -6
- package/src/ab/unpaired.ts +54 -0
- package/src/bench/index.ts +40 -3
- package/src/bench/registry.ts +6 -4
- package/src/bench/run-tasks.ts +16 -2
- package/src/bench/runner.ts +10 -3
- package/src/bench/support.ts +8 -4
- package/src/bench/sweep.ts +2 -2
- package/src/cache/fingerprint.ts +2 -2
- package/src/capture/bunflags.ts +2 -2
- package/src/capture/cpu.ts +2 -2
- package/src/capture/heap-parse.ts +2 -2
- package/src/ci/index.ts +39 -48
- package/src/cli/agent.ts +54 -0
- package/src/cli/flags.ts +58 -9
- package/src/cli/help.ts +670 -245
- package/src/cli/main.ts +2 -3
- package/src/cli/output.ts +17 -14
- package/src/cli/run.ts +317 -92
- package/src/compare/index.ts +4 -4
- package/src/config/index.ts +14 -10
- package/src/config/validate.ts +4 -4
- package/src/glob.ts +2 -2
- package/src/index.ts +3 -2
- package/src/ir/document.ts +2 -2
- package/src/ir/types.ts +49 -24
- package/src/measure/alloc.ts +2 -2
- package/src/measure/cpu.ts +2 -2
- package/src/measure/environment.ts +11 -6
- package/src/measure/inprocess.ts +14 -10
- package/src/measure/instructions.ts +2 -2
- package/src/measure/noise.ts +51 -13
- package/src/measure/paired.ts +2 -2
- package/src/measure/peak.ts +4 -4
- package/src/measure/timing.ts +27 -6
- package/src/profile.ts +6 -4
- package/src/renderers/collapsed.ts +2 -2
- package/src/renderers/concise.ts +148 -0
- package/src/renderers/format.ts +13 -4
- package/src/renderers/human.ts +402 -0
- package/src/renderers/index.ts +9 -2
- package/src/renderers/markdown.ts +2 -2
- package/src/renderers/mermaid.ts +2 -2
- package/src/renderers/minimal.ts +8 -7
- package/src/renderers/relative.ts +2 -2
- package/src/renderers/select.ts +2 -2
- package/src/renderers/terminal.ts +1178 -383
- package/src/renderers/types.ts +3 -0
- package/src/spawn/index.ts +47 -14
- package/src/stats/bootstrap.ts +2 -2
- package/src/stats/index.ts +2 -2
- package/src/terminal.ts +321 -0
- package/src/time.ts +124 -20
package/README.md
CHANGED
|
@@ -13,44 +13,45 @@ and every result is one JSON document.
|
|
|
13
13
|
```ts
|
|
14
14
|
// suite.ts
|
|
15
15
|
import { group, task } from "ostia"
|
|
16
|
+
import { dedupe } from "./dedupe.ts"
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
+
const ids = Array.from({ length: 2_000 }, (_, i) => (i * 7919) % 500)
|
|
18
19
|
|
|
19
|
-
group("
|
|
20
|
-
task("
|
|
21
|
-
task("
|
|
20
|
+
group("ids", () => {
|
|
21
|
+
task("dedupe 2,000", () => dedupe(ids))
|
|
22
|
+
task("sort 2,000", () => ids.toSorted((a, b) => a - b))
|
|
22
23
|
})
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Task Median Spread Range Relative
|
|
30
|
-
-----------------------------------------------------------------------------------------
|
|
31
|
-
dedupe:
|
|
32
|
-
naive (indexOf scan, O(n²)) 173.9 µs 180.4 µs…205.8 µs 170.1 µs…635.5 µs 7.40× slower
|
|
33
|
-
Set-based (O(n)) 23.5 µs 24.9 µs…72.5 µs 18.7 µs…208.3 µs 1.00×
|
|
34
|
-
```
|
|
26
|
+
<picture>
|
|
27
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/bench-dark.png">
|
|
28
|
+
<img alt="ostia bench suite.ts: 2 tasks, fastest dedupe 2,000 at 21.6 µs, sort 2,000 at 123 µs, each with its noise and instructions per call" src="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/bench-light.png">
|
|
29
|
+
</picture>
|
|
35
30
|
|
|
36
31
|
**It tells you when a change made something slower.**
|
|
37
|
-
|
|
38
|
-
and
|
|
32
|
+
Rewrite `dedupe` from a `Set` to `indexOf`,
|
|
33
|
+
and `ostia ab` runs your suite against `HEAD` and the working tree in
|
|
34
|
+
alternating batches in one process:
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
<picture>
|
|
37
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/ab-dark.png">
|
|
38
|
+
<img alt="ostia ab suite.ts after dedupe moved from a Set to indexOf: fail, dedupe 2,000 regressed +207%, confirmed by repeats in fresh processes, sort 2,000 unchanged, ending with the command to profile it" src="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/ab-light.png">
|
|
39
|
+
</picture>
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
------------------------------------------------------------------------------------------
|
|
46
|
-
dedupe:
|
|
47
|
-
naive (indexOf scan, O(n²)) 183.5 µs 178.5 µs -1.9% -3.5%…-0.3%
|
|
48
|
-
Set-based (O(n)) 25.2 µs 181.2 µs +618.1% +554.2%…+659.2% regressed, confirmed (repeats: +630.6%, +584.5%)
|
|
41
|
+
While it runs, one line says where it is:
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
<picture>
|
|
44
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/progress-dark.png">
|
|
45
|
+
<img alt="ostia ab's progress line: a bar at task 2 of 2, ids/sort 2,000" src="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/progress-light.png">
|
|
46
|
+
</picture>
|
|
52
47
|
|
|
53
48
|
Exit 1 on a regression, so CI can gate on it.
|
|
49
|
+
`ostia time` does the same for whole commands:
|
|
50
|
+
|
|
51
|
+
<picture>
|
|
52
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/time-dark.png">
|
|
53
|
+
<img alt="ostia time on gzip -1 and gzip -9 of the same file: gzip -1 is 12.9 times faster, with each command's noise and user and system time" src="https://raw.githubusercontent.com/metonym/ostia/master/.github/assets/time-light.png">
|
|
54
|
+
</picture>
|
|
54
55
|
ostia has no dependencies and needs Bun ≥ 1.4.
|
|
55
56
|
|
|
56
57
|
## Quick start
|
|
@@ -85,7 +86,7 @@ ostia ci
|
|
|
85
86
|
ostia time "bun a.ts" --cpu
|
|
86
87
|
|
|
87
88
|
# One JSON object per line, for a script or an agent
|
|
88
|
-
ostia bench suite.ts --format
|
|
89
|
+
ostia bench suite.ts --format events
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
These docs ship in the package, at `node_modules/ostia/docs/`.
|
|
@@ -114,14 +115,14 @@ const { text } = await renderers.markdown.render(doc, {})
|
|
|
114
115
|
|
|
115
116
|
## Docs
|
|
116
117
|
|
|
117
|
-
- [CLI](https://github.com/metonym/ostia/blob/master/docs/cli.md):
|
|
118
|
-
|
|
118
|
+
- [CLI](https://github.com/metonym/ostia/blob/master/docs/cli.md): every
|
|
119
|
+
command and flag
|
|
119
120
|
- [Library](https://github.com/metonym/ostia/blob/master/docs/library.md):
|
|
120
121
|
`time()`, `bench()`, `ab()`, `profile()`, and documents
|
|
121
122
|
- [Config](https://github.com/metonym/ostia/blob/master/docs/config.md):
|
|
122
123
|
`ostia.config` workloads, thresholds and baselines
|
|
123
124
|
- [Machine-readable output](https://github.com/metonym/ostia/blob/master/docs/agent-protocol.md):
|
|
124
|
-
`--format
|
|
125
|
+
`--format events`, exit codes and error codes, for scripts and agents
|
|
125
126
|
- [Statistics](https://github.com/metonym/ostia/blob/master/docs/statistics.md):
|
|
126
127
|
how a comparison decides, and the noise floor
|
|
127
128
|
- [Document schema](https://github.com/metonym/ostia/blob/master/docs/document-schema.md):
|
package/docs/agent-protocol.md
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# Machine-readable output
|
|
2
2
|
|
|
3
|
-
`--format
|
|
3
|
+
`--format events` is a line protocol for scripts
|
|
4
|
+
and LLM agents (`minimal`, its name until 0.5.0, still works):
|
|
4
5
|
one JSON object per line on stdout, nothing else.
|
|
6
|
+
Without `--format`, an agent gets `concise` text instead,
|
|
7
|
+
so a script that parses the output asks for `events` by name.
|
|
5
8
|
It drops the raw sample arrays and prose that make a full
|
|
6
9
|
`ProfileDocument` large.
|
|
7
10
|
It works on `time`, `bench`, `ab`, `compare`, `ci`,
|
|
8
11
|
`report` and `baseline show`.
|
|
9
12
|
|
|
10
13
|
```sh
|
|
11
|
-
ostia time --samples 10 "bun a.ts" --format
|
|
12
|
-
ostia bench bench/*.ts --format
|
|
13
|
-
ostia ab bench/*.ts --base origin/main --format
|
|
14
|
-
ostia compare before.json after.json --format
|
|
15
|
-
ostia ci --format
|
|
14
|
+
ostia time --samples 10 "bun a.ts" --format events
|
|
15
|
+
ostia bench bench/*.ts --format events
|
|
16
|
+
ostia ab bench/*.ts --base origin/main --format events
|
|
17
|
+
ostia compare before.json after.json --format events
|
|
18
|
+
ostia ci --format events; echo $?
|
|
16
19
|
```
|
|
17
20
|
|
|
18
21
|
`ostia ab` can run for many minutes.
|
|
@@ -146,7 +149,7 @@ Never emitted for `time`, `bench` or `report`.
|
|
|
146
149
|
| `verdict` | `"pass"` when `exitCode` is 0, `"fail"` when it is 1 (a regression), `"error"` otherwise: exit 2 (harness error) or 130 (cancelled), where no verdict was reached. |
|
|
147
150
|
| `exitCode` | The process's exit code. |
|
|
148
151
|
|
|
149
|
-
Example (`ostia ci --format
|
|
152
|
+
Example (`ostia ci --format events` after a regression):
|
|
150
153
|
|
|
151
154
|
```
|
|
152
155
|
{"event":"run","protocolVersion":2,"schemaVersion":2,"workloadId":"wl_11e8562f3622d528","task":"work","unit":"ns","samples":10,"batch":1,"mean":21012800,"median":20999900,"stddev":231456,"stddevPct":1.1015,"min":20664000,"max":21552300,"warnings":[{"code":"outliers-detected","data":{"mild":1,"severe":0}}],"p75":21086100,"p99":21517600,"mad":126625,"userNs":15519000,"systemNs":6015500,"noiseFloorPct":2.09286,"delta":{"medianPct":44.0989,"meanPct":43.9626,"verdict":"regressed","pass":false,"effectiveTimingPct":10,"matched":true,"ci95":[41.4394,45.5841],"pValue":0.000157103}}
|
|
@@ -170,8 +173,9 @@ and exits 2.
|
|
|
170
173
|
## Errors
|
|
171
174
|
|
|
172
175
|
On exit 2, stderr gets a prose message.
|
|
173
|
-
When stderr is not a TTY, or `--format` is `
|
|
174
|
-
one more line follows it as the last
|
|
176
|
+
When stderr is not a TTY, or `--format` is `events`,
|
|
177
|
+
`json` or `jsonl` (or `--json`), one more line follows it as the last
|
|
178
|
+
line of stderr:
|
|
175
179
|
|
|
176
180
|
```json
|
|
177
181
|
{"event":"error","protocolVersion":2,"code":"command-failed","message":"One or more commands failed to produce a clean measurement; see the report above for details."}
|