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/src/cli/main.ts
CHANGED
|
@@ -10,9 +10,8 @@ if (first === "--version" || first === "-v") {
|
|
|
10
10
|
process.exit(0);
|
|
11
11
|
}
|
|
12
12
|
if (first === undefined || first === "--help" || first === "-h") {
|
|
13
|
-
const {
|
|
14
|
-
await
|
|
15
|
-
process.exit(first === undefined ? 2 : 0);
|
|
13
|
+
const { showHelp } = await import("./help.ts");
|
|
14
|
+
process.exit(await showHelp("main", first !== undefined));
|
|
16
15
|
}
|
|
17
16
|
const { main } = await import("./run.ts");
|
|
18
17
|
process.exit(await main());
|
package/src/cli/output.ts
CHANGED
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
serializeDocument,
|
|
6
6
|
} from "../ir/document.ts";
|
|
7
7
|
import type { ProfileDocument } from "../ir/types.ts";
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
FormatName,
|
|
10
|
+
RenderResult,
|
|
11
|
+
TableOptions,
|
|
12
|
+
} from "../renderers/index.ts";
|
|
9
13
|
import { renderers } from "../renderers/index.ts";
|
|
10
14
|
import {
|
|
11
15
|
MINIMAL_PROTOCOL_VERSION,
|
|
@@ -69,7 +73,8 @@ export async function orFail<T>(
|
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
// `minimal` too, since this reads argv before the alias resolves.
|
|
77
|
+
const MACHINE_FORMATS = new Set(["events", "minimal", "json", "jsonl"]);
|
|
73
78
|
|
|
74
79
|
// Machine errors are for scripts and agents: stderr isn't a terminal, or a
|
|
75
80
|
// machine `--format` was asked for.
|
|
@@ -81,6 +86,8 @@ async function wantsMachineErrors(): Promise<boolean> {
|
|
|
81
86
|
const argv = process.argv.slice(2);
|
|
82
87
|
return argv.some(
|
|
83
88
|
(arg, i) =>
|
|
89
|
+
arg === "--json" ||
|
|
90
|
+
arg === "--json=true" ||
|
|
84
91
|
(arg === "--format" && MACHINE_FORMATS.has(argv[i + 1] ?? "")) ||
|
|
85
92
|
(arg.startsWith("--format=") &&
|
|
86
93
|
MACHINE_FORMATS.has(arg.slice("--format=".length))),
|
|
@@ -107,14 +114,6 @@ export async function writeCliError(
|
|
|
107
114
|
);
|
|
108
115
|
}
|
|
109
116
|
|
|
110
|
-
export async function showHelp(
|
|
111
|
-
text: string,
|
|
112
|
-
requested: boolean,
|
|
113
|
-
): Promise<0 | 2> {
|
|
114
|
-
await out(text);
|
|
115
|
-
return requested ? 0 : 2;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
117
|
export async function writeRenderResult(
|
|
119
118
|
result: RenderResult,
|
|
120
119
|
outDir?: string,
|
|
@@ -146,8 +145,8 @@ interface OutputOptions {
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
// Honors `--export-json`; returns the JSON text when `--format json` will
|
|
149
|
-
// print it (the json renderer's output is exactly this, so
|
|
150
|
-
// once).
|
|
148
|
+
// print it (the json renderer's output is exactly this, so
|
|
149
|
+
// serialize once).
|
|
151
150
|
export async function exportDocument(
|
|
152
151
|
doc: ProfileDocument,
|
|
153
152
|
{ exportJson, format, quiet }: OutputOptions,
|
|
@@ -162,16 +161,20 @@ export async function exportDocument(
|
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
// Shared tail of time/bench/ab/compare: `--export-json`, then the report
|
|
165
|
-
// unless `--quiet`. `rendererOptions` reaches the
|
|
164
|
+
// unless `--quiet`. `rendererOptions` reaches the event renderers
|
|
165
|
+
// verbatim, `tableOptions` the table.
|
|
166
166
|
export async function emitDocument(
|
|
167
167
|
doc: ProfileDocument,
|
|
168
168
|
args: OutputOptions,
|
|
169
169
|
rendererOptions: MinimalRenderOptions = {},
|
|
170
|
+
tableOptions: TableOptions = {},
|
|
170
171
|
): Promise<void> {
|
|
171
172
|
const jsonText = await exportDocument(doc, args);
|
|
172
173
|
if (args.quiet) return;
|
|
173
174
|
if (jsonText !== undefined) await out(jsonText);
|
|
174
|
-
else {
|
|
175
|
+
else if (args.format === "table") {
|
|
176
|
+
await writeRenderResult(await renderers.table.render(doc, tableOptions));
|
|
177
|
+
} else {
|
|
175
178
|
await writeRenderResult(
|
|
176
179
|
await renderers[args.format].render(doc, rendererOptions),
|
|
177
180
|
);
|