ostia 0.2.7 → 0.2.8
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 +68 -13
- package/chunk-17t12ta6.js +16 -0
- package/chunk-p3342c5c.js +25 -0
- package/cli.js +71 -34
- package/index.d.ts +200 -17
- package/index.js +1 -1
- package/package.json +1 -1
- package/runner.ts +16 -4
- package/chunk-5qtsmr3p.js +0 -21
- package/chunk-n02qf2mf.js +0 -16
package/index.d.ts
CHANGED
|
@@ -136,7 +136,9 @@ interface BenchConfig {
|
|
|
136
136
|
minSamples?: number;
|
|
137
137
|
gc?: boolean;
|
|
138
138
|
cpu?: boolean;
|
|
139
|
+
cpuIntervalUs?: number;
|
|
139
140
|
alloc?: boolean;
|
|
141
|
+
peakMem?: boolean;
|
|
140
142
|
filter?: string;
|
|
141
143
|
isolate?: boolean;
|
|
142
144
|
outDir?: string;
|
|
@@ -235,6 +237,11 @@ export interface ProfileDocument {
|
|
|
235
237
|
* schema bump. Absent when `noiseCheck: false` (or `--no-noise-check`)
|
|
236
238
|
* skipped the reference measurement. */
|
|
237
239
|
environment?: Environment;
|
|
240
|
+
/** Run-level result of a paired A/B run (`ostia ab` / `ab()`): what the
|
|
241
|
+
* candidate was paired against and the gate's verdict. Additive, no schema
|
|
242
|
+
* bump. Present only on documents from `ab()`, whose measurements are
|
|
243
|
+
* `phase: "paired"`. */
|
|
244
|
+
ab?: AbSummary;
|
|
238
245
|
/** Repo state when this document was measured, from `git rev-parse` /
|
|
239
246
|
* `git status --porcelain` in the process's cwd. Additive, no schema
|
|
240
247
|
* bump. Absent outside a git repo (or when `git` itself isn't
|
|
@@ -333,7 +340,7 @@ export interface Workload {
|
|
|
333
340
|
skipped?: boolean;
|
|
334
341
|
}
|
|
335
342
|
|
|
336
|
-
type Phase = "timing" | "cpu" | "heap" | "memstats";
|
|
343
|
+
type Phase = "timing" | "cpu" | "heap" | "memstats" | "paired";
|
|
337
344
|
|
|
338
345
|
interface Measurement {
|
|
339
346
|
id: string;
|
|
@@ -348,6 +355,9 @@ interface Measurement {
|
|
|
348
355
|
heap?: HeapEvidence;
|
|
349
356
|
memory?: MemoryEvidence;
|
|
350
357
|
jit?: JitTierBreakdown;
|
|
358
|
+
/** `phase: "paired"` only: the base side and the per-round ratios. The
|
|
359
|
+
* measurement's `timing` is the candidate side. */
|
|
360
|
+
paired?: PairedEvidence;
|
|
351
361
|
warnings: Warning[];
|
|
352
362
|
artifacts: ArtifactRef[];
|
|
353
363
|
/** True when this timing measurement's trials were run round-robin against
|
|
@@ -456,13 +466,26 @@ interface HeapEvidence {
|
|
|
456
466
|
|
|
457
467
|
interface MemoryEvidence {
|
|
458
468
|
origin: "resourceUsage" | "heapStats";
|
|
469
|
+
/** What a `phase: "memstats"` measurement measured: `"retained"` for
|
|
470
|
+
* `--alloc` (`bytesPerOp`), `"peak"` for `--peak-mem` (`peakBytes`).
|
|
471
|
+
* Absent on subprocess timing's `maxRssBytes`, and on `memstats`
|
|
472
|
+
* measurements written before this field existed, which are always
|
|
473
|
+
* `"retained"`. */
|
|
474
|
+
kind?: "retained" | "peak";
|
|
459
475
|
/** Largest `Trial.maxRssBytes` across a timing measurement's trials. */
|
|
460
476
|
maxRssBytes?: number;
|
|
461
|
-
/**
|
|
462
|
-
* (`bun:jsc`'s `heapStats().heapSize`, falling back to
|
|
463
|
-
* `process.memoryUsage().heapUsed`) around one
|
|
464
|
-
*
|
|
477
|
+
/** Retained heap growth per call, from `ostia bench --alloc`: heap size
|
|
478
|
+
* delta (`bun:jsc`'s `heapStats().heapSize`, falling back to
|
|
479
|
+
* `process.memoryUsage().heapUsed`) around one batch bracketed by
|
|
480
|
+
* `Bun.gc(true)` on both sides, divided by the batch size. Garbage the
|
|
481
|
+
* calls create and drop is collected before the second reading, so this
|
|
482
|
+
* is what the calls keep alive (a leak check), not what they allocate. */
|
|
465
483
|
bytesPerOp?: number;
|
|
484
|
+
/** How far one call raised the process's RSS above where it started,
|
|
485
|
+
* garbage included, from `ostia bench --peak-mem`: median over 3 fresh
|
|
486
|
+
* processes, each making the task's first call after its `before` hooks
|
|
487
|
+
* and a full GC. A `peak-hidden` warning says when it may read low. */
|
|
488
|
+
peakBytes?: number;
|
|
466
489
|
}
|
|
467
490
|
|
|
468
491
|
interface JitTierBreakdown {
|
|
@@ -480,7 +503,73 @@ interface JitTierBreakdown {
|
|
|
480
503
|
}[];
|
|
481
504
|
}
|
|
482
505
|
|
|
483
|
-
|
|
506
|
+
interface PairedEvidence {
|
|
507
|
+
/** Rounds run: one base batch and one candidate batch each, alternating
|
|
508
|
+
* which goes first. */
|
|
509
|
+
rounds: number;
|
|
510
|
+
/** Calls per side per round. */
|
|
511
|
+
batch: number;
|
|
512
|
+
/** Base per-call time for each round, ns; `ratios[i]` pairs with
|
|
513
|
+
* `baseSamples[i]` and the candidate's `timing.samples[i]`. */
|
|
514
|
+
baseSamples: number[];
|
|
515
|
+
baseMedianNs: number;
|
|
516
|
+
/** Candidate/base time per round. */
|
|
517
|
+
ratios: number[];
|
|
518
|
+
medianRatio: number;
|
|
519
|
+
/** 25th/75th percentile of `ratios`. */
|
|
520
|
+
p25: number;
|
|
521
|
+
p75: number;
|
|
522
|
+
/** Set when this process's rounds crossed the threshold: median ratio
|
|
523
|
+
* past `1 ± threshold` and on the same side of 1 in at least three
|
|
524
|
+
* quarters of rounds. */
|
|
525
|
+
flagged?: "regressed" | "improved";
|
|
526
|
+
/** Each fresh-process re-measurement of a flagged workload. */
|
|
527
|
+
repeats?: {
|
|
528
|
+
medianRatio: number;
|
|
529
|
+
p25: number;
|
|
530
|
+
p75: number;
|
|
531
|
+
flagged?: "regressed" | "improved";
|
|
532
|
+
}[];
|
|
533
|
+
/** Set when `flagged` is: whether every repeat flagged the same way. */
|
|
534
|
+
confirmed?: boolean;
|
|
535
|
+
/** `flagged` when confirmed, else `"unchanged"`. */
|
|
536
|
+
verdict: "regressed" | "improved" | "unchanged";
|
|
537
|
+
/** Whether the first call's return value was deep-equal on both sides
|
|
538
|
+
* (`Bun.deepEquals`, prototypes ignored). Informational: expected to be
|
|
539
|
+
* `false` for a change in behavior, never a failure. */
|
|
540
|
+
sameOutput: boolean;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
interface AbSummary {
|
|
544
|
+
base: {
|
|
545
|
+
ref: string;
|
|
546
|
+
sha: string;
|
|
547
|
+
};
|
|
548
|
+
rounds: number;
|
|
549
|
+
thresholdPct: number;
|
|
550
|
+
geomeanThresholdPct: number;
|
|
551
|
+
/** Workloads measured on both sides. */
|
|
552
|
+
matched: number;
|
|
553
|
+
/** Confirmed verdicts. */
|
|
554
|
+
regressed: number;
|
|
555
|
+
improved: number;
|
|
556
|
+
unchanged: number;
|
|
557
|
+
/** Flagged in-process, but a fresh-process repeat disagreed; counted in
|
|
558
|
+
* `unchanged`. */
|
|
559
|
+
unconfirmed: number;
|
|
560
|
+
/** Workloads whose first call returned different values on each side. */
|
|
561
|
+
outputDiffers: number;
|
|
562
|
+
/** Geometric mean of each workload's median ratio, as a signed percent
|
|
563
|
+
* (negative: candidate faster on average). A flagged workload contributes
|
|
564
|
+
* the median over its main run and repeats. `null` when nothing was
|
|
565
|
+
* paired. */
|
|
566
|
+
geomeanPct: number | null;
|
|
567
|
+
/** `"fail"` when any workload regressed (confirmed) or `geomeanPct`
|
|
568
|
+
* exceeds `geomeanThresholdPct`. */
|
|
569
|
+
verdict: "pass" | "fail";
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
declare const WARNING_CODES: readonly ["slow-first-run", "outliers-detected", "fast-command", "nonzero-exit", "artifact-missing", "empty-profile", "low-sample-count", "thin-comparison", "noisy-machine", "skipped", "jit-cold", "timeout", "aborted", "time-source-no-match", "environment-mismatch", "peak-hidden"];
|
|
484
573
|
|
|
485
574
|
export type WarningCode = (typeof WARNING_CODES)[number];
|
|
486
575
|
|
|
@@ -611,6 +700,42 @@ interface InprocessTimingOptions {
|
|
|
611
700
|
|
|
612
701
|
export declare function keep(value: unknown): void;
|
|
613
702
|
|
|
703
|
+
interface AbOptions {
|
|
704
|
+
suites: string[];
|
|
705
|
+
/** Git ref whose committed tree is the base side (default: `"HEAD"`). The
|
|
706
|
+
* candidate is the working tree, uncommitted changes included. */
|
|
707
|
+
base?: string;
|
|
708
|
+
/** Rounds per workload, each one base batch and one candidate batch of
|
|
709
|
+
* about 10ms (default: 15). */
|
|
710
|
+
rounds?: number;
|
|
711
|
+
/** Flag a workload whose median candidate/base ratio moves past this many
|
|
712
|
+
* percent (default: 10). */
|
|
713
|
+
thresholdPct?: number;
|
|
714
|
+
/** Fail when the geometric mean of all workloads' ratios is slower than
|
|
715
|
+
* this many percent (default: 1.5): a broad slowdown too small to flag any
|
|
716
|
+
* one workload. */
|
|
717
|
+
geomeanThresholdPct?: number;
|
|
718
|
+
/** Fresh-process repeats of each flagged workload; it only counts when
|
|
719
|
+
* every repeat flags it the same way (default: 2; 0 trusts the first
|
|
720
|
+
* process). */
|
|
721
|
+
confirm?: number;
|
|
722
|
+
filter?: string;
|
|
723
|
+
preload?: string[];
|
|
724
|
+
bunFlags?: string[];
|
|
725
|
+
outDir?: string;
|
|
726
|
+
cwd?: string;
|
|
727
|
+
noiseCheck?: boolean;
|
|
728
|
+
/** Kills a runner process (one suite file, or one repeat) after this many
|
|
729
|
+
* ms. No default. */
|
|
730
|
+
timeoutMs?: number;
|
|
731
|
+
/** Aborting kills the running process and resolves with the suites that
|
|
732
|
+
* had finished, plus an `aborted` warning; repeats not yet run leave their
|
|
733
|
+
* workloads unconfirmed. */
|
|
734
|
+
signal?: AbortSignal;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export declare function ab(opts: AbOptions): Promise<ProfileDocument>;
|
|
738
|
+
|
|
614
739
|
interface BenchOptions {
|
|
615
740
|
suites: string[];
|
|
616
741
|
/** Wall-clock sampling budget per task, ms (default 500). */
|
|
@@ -620,16 +745,27 @@ interface BenchOptions {
|
|
|
620
745
|
samples?: number;
|
|
621
746
|
minSamples?: number;
|
|
622
747
|
gc?: boolean;
|
|
623
|
-
/** Capture one extra `phase: "cpu"` measurement per task (
|
|
624
|
-
*
|
|
625
|
-
* mixed into the timing numbers.
|
|
626
|
-
* override this per task or group. */
|
|
748
|
+
/** Capture one extra `phase: "cpu"` measurement per task (the task looped
|
|
749
|
+
* under the JSC sampling profiler for long enough to collect ~2,000
|
|
750
|
+
* samples, JIT tiers included), never mixed into the timing numbers.
|
|
751
|
+
* `TaskOptions.cpu` / `GroupOptions.cpu` override this per task or group. */
|
|
627
752
|
cpu?: boolean;
|
|
628
|
-
/**
|
|
629
|
-
*
|
|
630
|
-
|
|
631
|
-
|
|
753
|
+
/** `cpu`'s sampling interval, µs (default: 100). A coarser interval
|
|
754
|
+
* lengthens the capture to keep the sample count, up to 10s per task. */
|
|
755
|
+
cpuIntervalUs?: number;
|
|
756
|
+
/** Capture one extra `phase: "memstats"` measurement per task: retained
|
|
757
|
+
* heap growth per call, from a batch with `Bun.gc(true)` on both sides.
|
|
758
|
+
* What the calls keep alive, not what they allocate - garbage is collected
|
|
759
|
+
* before the second reading. `TaskOptions.alloc` / `GroupOptions.alloc`
|
|
760
|
+
* override this per task or group. */
|
|
632
761
|
alloc?: boolean;
|
|
762
|
+
/** Capture one extra `phase: "memstats"` measurement per task: how far the
|
|
763
|
+
* task's first call raises RSS, garbage included - the reading
|
|
764
|
+
* `alloc` can't give. Median of 3 fresh processes, each run with
|
|
765
|
+
* `OSTIA_PEAK_MEM=1` in its environment (see `measurePeakMem`).
|
|
766
|
+
* `TaskOptions.peakMem` / `GroupOptions.peakMem` override this per task or
|
|
767
|
+
* group. */
|
|
768
|
+
peakMem?: boolean;
|
|
633
769
|
filter?: string;
|
|
634
770
|
/** Suite files to run at once, each still in its own child process (default:
|
|
635
771
|
* 1). Files are independent by design, so this is a wall-clock win for
|
|
@@ -720,9 +856,14 @@ export interface TaskOptions {
|
|
|
720
856
|
cpu?: boolean;
|
|
721
857
|
/** Overrides the suite-wide `bench({ alloc })` / `--alloc` (and any
|
|
722
858
|
* `GroupOptions.alloc`) for this task only: after the timing measurement,
|
|
723
|
-
* capture one extra `phase: "memstats"` measurement
|
|
724
|
-
*
|
|
859
|
+
* capture one extra `phase: "memstats"` measurement of the heap each call
|
|
860
|
+
* retains (what survives a full GC, not what it allocates). */
|
|
725
861
|
alloc?: boolean;
|
|
862
|
+
/** Overrides the suite-wide `bench({ peakMem })` / `--peak-mem` (and any
|
|
863
|
+
* `GroupOptions.peakMem`) for this task only: capture one extra
|
|
864
|
+
* `phase: "memstats"` measurement of how far one call raises the
|
|
865
|
+
* process's peak RSS, in fresh processes. */
|
|
866
|
+
peakMem?: boolean;
|
|
726
867
|
/** Structured parameters this task represents (e.g. `{ size: 800, impl:
|
|
727
868
|
* "fast" }`), written to `Workload.params` and folded into the workload id
|
|
728
869
|
* so points with the same task name don't collide. Inside `sweep()`, the
|
|
@@ -755,6 +896,9 @@ export interface GroupOptions {
|
|
|
755
896
|
/** Default `alloc` for every task in this group, unless a task overrides
|
|
756
897
|
* it with its own `TaskOptions.alloc`. */
|
|
757
898
|
alloc?: boolean;
|
|
899
|
+
/** Default `peakMem` for every task in this group, unless a task
|
|
900
|
+
* overrides it with its own `TaskOptions.peakMem`. */
|
|
901
|
+
peakMem?: boolean;
|
|
758
902
|
/** Runs once, unmeasured, before the group's first task's warmup (not
|
|
759
903
|
* before every task) - in whichever process runs that task, so it works
|
|
760
904
|
* with `isolate`. */
|
|
@@ -823,6 +967,8 @@ interface MeasureTasksOpts extends InprocessTimingOptions {
|
|
|
823
967
|
/** Suite-wide default for capturing an extra `phase: "cpu"` measurement
|
|
824
968
|
* per task (task/group `TaskOptions.cpu`/`GroupOptions.cpu` still win). */
|
|
825
969
|
cpu?: boolean;
|
|
970
|
+
/** `cpu`'s sampling interval, µs (default: 100). */
|
|
971
|
+
cpuIntervalUs?: number;
|
|
826
972
|
/** Suite-wide default for capturing an extra `phase: "memstats"`
|
|
827
973
|
* measurement per task (task/group `TaskOptions.alloc`/`GroupOptions.alloc`
|
|
828
974
|
* still win). */
|
|
@@ -885,6 +1031,24 @@ interface MinimalDelta {
|
|
|
885
1031
|
matched: true;
|
|
886
1032
|
}
|
|
887
1033
|
|
|
1034
|
+
interface MinimalPaired {
|
|
1035
|
+
/** Base side's median per-call time, ns. */
|
|
1036
|
+
baseMedian: number;
|
|
1037
|
+
medianRatio: number;
|
|
1038
|
+
p25: number;
|
|
1039
|
+
p75: number;
|
|
1040
|
+
rounds: number;
|
|
1041
|
+
/** Final: `flagged` when fresh processes confirmed it, else
|
|
1042
|
+
* `"unchanged"`. */
|
|
1043
|
+
verdict: "regressed" | "improved" | "unchanged";
|
|
1044
|
+
/** What this workload's first process saw, before confirmation. */
|
|
1045
|
+
flagged?: "regressed" | "improved";
|
|
1046
|
+
confirmed?: boolean;
|
|
1047
|
+
/** Median ratio of each fresh-process repeat. */
|
|
1048
|
+
repeats?: number[];
|
|
1049
|
+
sameOutput: boolean;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
888
1052
|
interface MinimalRunLine {
|
|
889
1053
|
event: "run";
|
|
890
1054
|
protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
|
|
@@ -923,6 +1087,10 @@ interface MinimalRunLine {
|
|
|
923
1087
|
/** Median user / system CPU time per trial, ns: subprocess commands only. */
|
|
924
1088
|
userNs?: number;
|
|
925
1089
|
systemNs?: number;
|
|
1090
|
+
/** `--alloc`: heap each call keeps alive after a full GC, whole bytes. */
|
|
1091
|
+
retainedBytesPerOp?: number;
|
|
1092
|
+
/** `--peak-mem`: how far the task's first call raised RSS, bytes. */
|
|
1093
|
+
peakBytes?: number;
|
|
926
1094
|
/** Median over the group's reference median (its baseline task, else its
|
|
927
1095
|
* fastest). Only present when the document has more than one timing run. */
|
|
928
1096
|
relative?: number;
|
|
@@ -935,6 +1103,8 @@ interface MinimalRunLine {
|
|
|
935
1103
|
/** From `comparisons` when present (ostia compare / ci): the change against
|
|
936
1104
|
* the baseline document for this task. */
|
|
937
1105
|
delta?: MinimalDelta;
|
|
1106
|
+
/** `ab` only; see `MinimalPaired`. */
|
|
1107
|
+
paired?: MinimalPaired;
|
|
938
1108
|
}
|
|
939
1109
|
|
|
940
1110
|
interface MinimalUnmatchedLine {
|
|
@@ -948,7 +1118,7 @@ interface MinimalUnmatchedLine {
|
|
|
948
1118
|
interface MinimalSummaryLine {
|
|
949
1119
|
event: "summary";
|
|
950
1120
|
protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
|
|
951
|
-
command: "compare" | "ci";
|
|
1121
|
+
command: "compare" | "ci" | "ab";
|
|
952
1122
|
matched: number;
|
|
953
1123
|
regressed: number;
|
|
954
1124
|
improved: number;
|
|
@@ -967,6 +1137,19 @@ interface MinimalSummaryLine {
|
|
|
967
1137
|
name: string;
|
|
968
1138
|
path: string;
|
|
969
1139
|
};
|
|
1140
|
+
/** `ab` only: the git ref the working tree was paired against. */
|
|
1141
|
+
base?: {
|
|
1142
|
+
ref: string;
|
|
1143
|
+
sha: string;
|
|
1144
|
+
};
|
|
1145
|
+
/** `ab` only: the gate on `geomeanPct`. */
|
|
1146
|
+
geomeanThresholdPct?: number;
|
|
1147
|
+
/** `ab` only: flagged in the first process but not reproduced by the
|
|
1148
|
+
* fresh-process repeats; counted in `unchanged`. */
|
|
1149
|
+
unconfirmed?: number;
|
|
1150
|
+
/** `ab` only: workloads whose first call returned different values on the
|
|
1151
|
+
* two sides. Informational. */
|
|
1152
|
+
outputDiffers?: number;
|
|
970
1153
|
git?: {
|
|
971
1154
|
base?: GitMetadata;
|
|
972
1155
|
cand?: GitMetadata;
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{d,L,j,S,ge,f,m,he,be,we,oe,ke}from"./chunk-p3342c5c.js";import{r,l,M,s,ye,xe,Pe}from"./chunk-17t12ta6.js";export{d as DEFAULT_THRESHOLDS,f as MINIMAL_PROTOCOL_VERSION,M as OstiaDocumentError,j as ab,S as bench,L as compareDocuments,r as createDocument,we as defineConfig,xe as group,ye as keep,s as loadDocument,ke as profile,ge as range,m as renderers,he as run,l as saveDocument,be as sweep,Pe as task,oe as time};
|
package/package.json
CHANGED
package/runner.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import{l,v,W,de,A,ie,fe,U,ee,_}from"./chunk-17t12ta6.js";import{heapStats as w}from"bun:jsc";function k(){let{heapSize:e,extraMemorySize:r}=w();return{rssBytes:process.memoryUsage.rss(),liveBytes:e+r}}var n={ready:1,go:2,sampling:3,stop:4},h=`self.onmessage = (event) => {
|
|
4
|
+
const slots = new Int32Array(event.data)
|
|
5
|
+
Atomics.store(slots, 0, ${n.ready})
|
|
6
|
+
Atomics.wait(slots, 0, ${n.ready})
|
|
7
|
+
if (Atomics.compareExchange(slots, 0, ${n.go}, ${n.sampling}) === ${n.go}) {
|
|
8
|
+
while (Atomics.load(slots, 0) === ${n.sampling}) {
|
|
9
|
+
const kib = (process.memoryUsage.rss() / 1024) | 0
|
|
10
|
+
if (kib > Atomics.load(slots, 1)) Atomics.store(slots, 1, kib)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
postMessage(0)
|
|
14
|
+
}`;async function y(){let e=new Int32Array(new SharedArrayBuffer(8)),r=new Worker(URL.createObjectURL(new Blob([h],{type:"application/javascript"}))),i=new Promise((s)=>{r.onmessage=s});r.postMessage(e.buffer);while(Atomics.load(e,0)!==n.ready)await Bun.sleep(1);return{async during(s){try{Atomics.store(e,0,n.go),Atomics.notify(e,0);while(Atomics.load(e,0)!==n.sampling);return await s(),Atomics.store(e,0,n.stop),await i,Atomics.load(e,1)*1024}finally{r.terminate()}}}}async function g(e,r,i){let s=i??await y();Bun.gc(!0);let m=k(),p=process.resourceUsage().maxRSS*1024,c=Bun.nanoseconds(),o=0,f=await s.during(async()=>{let d=e();if(v(d))await d;o=Bun.nanoseconds()-c}),u=process.resourceUsage().maxRSS*1024,t=Math.max(f,u>p?u:0),a=r?m.rssBytes-r.rssBytes-(m.liveBytes-r.liveBytes):0;return{peakBytes:Math.max(0,t-m.rssBytes),slackBytes:Math.max(0,a),wallNs:o}}async function S(){let[e,r,i]=process.argv.slice(2);if(!e||!r)return process.stderr.write(`bench runner: usage: runner.ts <suiteFile> <outputPath> [optsJson]
|
|
15
|
+
`),2;let s=i?JSON.parse(i):{},m,p;if(s.peakMemFor)p=await y(),await import("./index.js"),m=k();for(let t of s.preload??[])await import(t);de(),await import(e);let c=W();if(c.length===0)return process.stderr.write(`bench runner: ${e} registered no tasks (no task() calls found).
|
|
16
|
+
`),2;let o;try{o=U(c,s.filter,e)}catch(t){return process.stderr.write(`bench runner: ${t.message}
|
|
17
|
+
`),2}if(s.taskIds){let t=new Set(s.taskIds);o=o.filter((a)=>t.has(A(a)))}if(s.peakMemFor){let t=o.find((d)=>ee(e,d).id===s.peakMemFor);if(!t)return process.stderr.write(`bench runner: no task with workload id ${s.peakMemFor} in ${e}.
|
|
18
|
+
`),2;await t.groupBefore?.(),await t.opts?.before?.();let a=await g(t.fn,m,p);return await t.opts?.after?.(),await t.groupAfter?.(),await Bun.write(r,JSON.stringify(a)),0}if(s.planPath){let t=o.map((a)=>({id:A(a),workloadId:ee(e,a).id,isolate:ie(a,s.isolate??!1),peakMem:!a.skipped&&fe(a,s.peakMem??!1)}));await Bun.write(s.planPath,JSON.stringify({tasks:t}))}let f=s.taskIds?o:o.filter((t)=>!ie(t,s.isolate??!1)),u=await _(e,f,s);return await l(u,r),0}S().then((e)=>process.exit(e));
|
package/chunk-5qtsmr3p.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{T,e,M,S,n,U,g,t,L,te,h,_,f,a,j,H,V,re,G,b,r,I,se,w,y,oe,c,k,s,l,d,z,O,ae,D,N}from"./chunk-n02qf2mf.js";function Xe(u,R,x){let C=u[0];if(C==="bun"||C?.endsWith("/bun"))return{argv:[C,...R,...u.slice(1)],env:x};return{argv:u,env:{...process.env,...x,BUN_OPTIONS:R.join(" ")}}}function Zn(u){return u.startsWith("file://")?u.slice(7):u}function Ze(u,R,x){let C=u.nodes,J=C.length,fe=new Map,ie=[],ee=new Map,he=new Int32Array(J);for(let be=0;be<J;be++){let Ce=C[be],ke=Ce.callFrame,Re=Zn(ke.url),ve=fe.get(ke.functionName);if(ve===void 0)ve=new Map,fe.set(ke.functionName,ve);let Te=ve.get(Re);if(Te===void 0)Te=ie.length,ve.set(Re,Te),ie.push({key:e("fr",ke.functionName,Re),name:ke.functionName,url:Re||void 0,line:ke.lineNumber>=0?ke.lineNumber:void 0,col:ke.columnNumber>=0?ke.columnNumber:void 0});he[be]=Te,ee.set(Ce.id,be)}let pe=Array(J);for(let be=0;be<J;be++){let Ce=C[be];pe[be]={id:Ce.id,frameIx:he[ee.get(Ce.id)],children:Ce.children??[]}}let ge=new Float64Array(J),xe=new Float64Array(J),{samples:we,timeDeltas:ye}=u;for(let be=0;be<we.length;be++){let Ce=ee.get(we[be]);if(Ce===void 0)continue;ge[Ce]+=ye[be]??0,xe[Ce]+=1}let Pe=new Int32Array(J).fill(-1);for(let be=0;be<J;be++){let Ce=C[be].children;if(!Ce)continue;for(let ke of Ce){let Re=ee.get(ke);if(Re!==void 0)Pe[Re]=be}}let $e=[],Me=[];for(let be=J-1;be>=0;be--)if(Pe[be]===-1)Me.push(be);while(Me.length>0){let be=Me.pop();$e.push(be);let Ce=C[be].children;if(!Ce)continue;for(let ke of Ce){let Re=ee.get(ke);if(Re!==void 0&&Pe[Re]===be)Me.push(Re)}}let Ie=new Float64Array(J);for(let be=$e.length-1;be>=0;be--){let Ce=$e[be];Ie[Ce]+=ge[Ce];let ke=Pe[Ce];if(ke>=0)Ie[ke]+=Ie[Ce]}let Oe=Array(ie.length),Se=[];for(let be=0;be<J;be++){let Ce=pe[be].frameIx,ke=Oe[Ce];if(ke)ke.selfUs+=ge[be],ke.totalUs+=Ie[be],ke.samples+=xe[be];else{let Re={frameIx:Ce,selfUs:ge[be],totalUs:Ie[be],samples:xe[be]};Oe[Ce]=Re,Se.push(Re)}}return{origin:R,samplingIntervalUs:x,frames:ie,nodes:pe,totals:Se.sort((be,Ce)=>Ce.selfUs-be.selfUs),samples:{nodeIds:u.samples,timeDeltasUs:u.timeDeltas}}}async function fn(u){let R=`${u.artifactDir}/${u.fileName}`,{argv:x,env:C}=Xe(u.argv,["--cpu-prof","--cpu-prof-dir",u.artifactDir,"--cpu-prof-name",u.fileName,"--cpu-prof-interval",String(u.intervalUs)],u.env),J=Bun.nanoseconds(),ie=await Bun.spawn(x,{cwd:u.cwd,env:C,stdout:"ignore",stderr:"ignore",stdin:"ignore"}).exited,ee=Bun.nanoseconds()-J,he=Bun.file(R);if(!await he.exists())return{diagnosticWallNs:ee,exitCode:ie,warnings:[{code:"artifact-missing",message:`Expected a .cpuprofile at ${R} after exit ${ie}, found nothing. The workload's argv[0] must be a \`bun\` binary for CPU capture.`,data:{artifactPath:R,argv:u.argv}}]};let pe=await he.json(),ge=Ze(pe,"cpu-prof",u.intervalUs),xe=pe.samples.length===0?[{code:"empty-profile",message:"CPU capture produced zero samples."}]:[];return{diagnosticWallNs:ee,exitCode:ie,artifactPath:R,cpu:ge,warnings:xe}}function gn(u){let{node_fields:x,node_types:C}=u.snapshot.meta,J=x.indexOf("type"),fe=x.indexOf("self_size"),ie=x.length,ee=C[0];if(J===-1||fe===-1||!Array.isArray(ee))return{origin:"heap-prof",typeCounts:[],objectCount:u.snapshot.node_count};let he=ee.length,pe=Array(he),ge=new Map,xe=[],we=0,ye=u.nodes,Pe=ye.length;for(let Se=0;Se<Pe;Se+=ie){let be=ye[Se+J],Ce=ye[Se+fe]??0;we+=Ce;let ke;if(be>=0&&be<he){if(ke=pe[be],ke===void 0)ke={type:ee[be],count:0,bytes:0},pe[be]=ke,xe.push(ke)}else{let Re=`unknown(${be})`;if(ke=ge.get(Re),ke===void 0)ke={type:Re,count:0,bytes:0},ge.set(Re,ke),xe.push(ke)}ke.count++,ke.bytes+=Ce}let $e=xe.sort((Se,be)=>be.count-Se.count),Me=$e.slice(0,20),Ie=$e.slice(20),Oe=Me.map(({type:Se,count:be,bytes:Ce})=>({type:Se,count:be,retainedBytes:Ce}));if(Ie.length>0){let Se=0,be=0;for(let Ce of Ie)Se+=Ce.count,be+=Ce.bytes;Oe.push({type:"other",count:Se,retainedBytes:be})}return{origin:"heap-prof",heapSizeBytes:we,objectCount:u.snapshot.node_count,typeCounts:Oe}}async function hn(u){let R=`${u.artifactDir}/${u.fileName}`,{argv:x,env:C}=Xe(u.argv,["--heap-prof","--heap-prof-dir",u.artifactDir,"--heap-prof-name",u.fileName],u.env),J=Bun.nanoseconds(),ie=await Bun.spawn(x,{cwd:u.cwd,env:C,stdout:"ignore",stderr:"ignore",stdin:"ignore"}).exited,ee=Bun.nanoseconds()-J,he=Bun.file(R);if(!await he.exists())return{diagnosticWallNs:ee,exitCode:ie,warnings:[{code:"artifact-missing",message:`Expected a heap snapshot at ${R} after exit ${ie}, found nothing. The workload's argv[0] must be a \`bun\` binary for heap capture.`,data:{artifactPath:R,argv:u.argv}}]};let pe=await he.json(),ge=gn(pe);return{diagnosticWallNs:ee,exitCode:ie,artifactPath:R,heap:ge,warnings:[]}}var et=1000;async function bn(u,R={}){let x=R.intervalUs??et,{Session:C}=await import("inspector/promises"),J=new C;J.connect();let fe=Bun.nanoseconds();try{await J.post("Profiler.enable"),await J.post("Profiler.setSamplingInterval",{interval:x}),await J.post("Profiler.start");let ie=await u(),{profile:ee}=await J.post("Profiler.stop"),he=Bun.nanoseconds()-fe,pe=Ze(ee,"inspector",x);return{result:ie,cpu:pe,diagnosticWallNs:he}}finally{J.disconnect()}}function nt(u){let R=u>>>0;return()=>{R=R+1831565813|0;let x=Math.imul(R^R>>>15,1|R);return x=x+Math.imul(x^x>>>7,61|x)^x,((x^x>>>14)>>>0)/4294967296}}var en=2000,tt=2000;function rt(u){let R=u.length,x=R>>1;return R%2===0?(u[x-1]+u[x])/2:u[x]}function wn(u,R,x){if(u.length<=x)return u;let C=[...u];for(let J=0;J<x;J++){let fe=J+Math.floor(R()*(C.length-J)),ie=C[J];C[J]=C[fe],C[fe]=ie}return C.slice(0,x)}class an{sorted;rankOf;counts;n;constructor(u){let R=u.length,x=new Uint32Array(R);for(let C=0;C<R;C++)x[C]=C;x.sort((C,J)=>u[C]-u[J]),this.sorted=new Float64Array(R),this.rankOf=new Uint32Array(R);for(let C=0;C<R;C++)this.sorted[C]=u[x[C]],this.rankOf[x[C]]=C;this.n=R,this.counts=new Uint32Array(R)}resampleMedian(u){let{n:R,counts:x,sorted:C,rankOf:J}=this;x.fill(0);for(let pe=0;pe<R;pe++)x[J[Math.floor(u()*R)]]++;let fe=R+1>>1,ie=R%2===0?fe+1:fe,ee=0,he=-1;for(let pe=0;pe<R;pe++){if(ee+=x[pe],he<0&&ee>=fe)he=pe;if(ee>=ie)return he===pe?C[pe]:(C[he]+C[pe])/2}return C[R-1]}}function it(u,R){let x=new Float64Array(u.length+R.length+1);return x.set(u),x[u.length]=Number.NaN,x.set(R,u.length+1),Bun.hash.crc32(x)}function yn(u,R,x={}){let C=x.seed??it(u,R),J=nt(C),fe=x.iterations??tt,ie=u.length>en||R.length>en,ee=new an(wn(u,J,en)),he=new an(wn(R,J,en)),pe=rt(ee.sorted),ge=new Float64Array(fe);for(let xe=0;xe<fe;xe++){let we=ee.resampleMedian(J),ye=he.resampleMedian(J);ge[xe]=pe===0?ye-we===0?0:1/0:(ye-we)/pe*100}return ge.sort(),{ci95:[a(ge,0.025),a(ge,0.975)],seed:C,data:{subsampled:ie,iterations:fe}}}function st(u){let R=u<0?-1:1,x=Math.abs(u),C=0.254829592,J=-0.284496736,fe=1.421413741,ie=-1.453152027,ee=1.061405429,he=0.3275911,pe=1/(1+0.3275911*x),ge=1-((((1.061405429*pe+-1.453152027)*pe+1.421413741)*pe+-0.284496736)*pe+0.254829592)*pe*Math.exp(-x*x);return R*ge}function ot(u){return 0.5*(1+st(u/Math.SQRT2))}function xn(u,R){let x=u.length,C=R.length,J=x+C,fe=new Float64Array(u),ie=new Float64Array(R);fe.sort(),ie.sort();let ee=0,he=0,pe=0,ge=0,xe=0;while(pe<x||ge<C){let Ie=ge>=C||pe<x&&fe[pe]<=ie[ge]?fe[pe]:ie[ge],Oe=0;while(pe<x&&fe[pe]===Ie)Oe++,pe++;let Se=0;while(ge<C&&ie[ge]===Ie)Se++,ge++;let be=Oe+Se,Ce=xe+(be+1)/2;if(ee+=Oe*Ce,be>1)he+=be**3-be;xe+=be}let we=ee-x*(x+1)/2,ye=x*C/2,Pe=Math.sqrt(x*C*(J+1-he/(J*(J-1)))/12),$e=Pe===0?0:(we-ye)/Pe,Me=Math.min(1,Math.max(0,2*(1-ot(Math.abs($e)))));return{u:we,z:$e,pValue:Me}}var m={timingPct:5,frameSelfPct:10,heapTypePct:10,minFrameSelfUs:1000,alpha:0.01,bootstrapIterations:2000},mn=5;function nn(u,R){if(u===0)return R===0?0:1/0;return(R-u)/u*100}function Pn(u){let R=new Map;for(let x of u.measurements){let C=`${x.workloadId}\x00${x.phase}`;if(!R.has(C))R.set(C,x)}return R}function at(u,R,x){return{base:u,cand:R,baseByPhase:Pn(u),candByPhase:Pn(R),candWorkloads:new Map(R.workloads.map((C)=>[C.id,C])),environmentMismatch:mt(u,R),effectiveTimingPct:Math.max(x.timingPct,u.environment?.noise.floorPct??0,R.environment?.noise.floorPct??0)}}function mt(u,R){let x=[];if(u.platform.os!==R.platform.os)x.push({field:"platform.os",base:u.platform.os,cand:R.platform.os});if(u.platform.arch!==R.platform.arch)x.push({field:"platform.arch",base:u.platform.arch,cand:R.platform.arch});if(u.bunVersion!==R.bunVersion)x.push({field:"bunVersion",base:u.bunVersion,cand:R.bunVersion});if(u.environment&&R.environment){if(u.environment.cpuModel!==R.environment.cpuModel)x.push({field:"cpuModel",base:u.environment.cpuModel,cand:R.environment.cpuModel});if(u.environment.cores!==R.environment.cores)x.push({field:"cores",base:u.environment.cores,cand:R.environment.cores})}if(x.length===0)return;return{code:"environment-mismatch",message:`Base and candidate were measured on different environments (${x.map((C)=>C.field).join(", ")}); a timing delta may reflect that instead of the code change.`,data:{fields:x}}}function ct(u){let R=[];for(let C of u){if(!C.timing)continue;let J=1+C.timing.medianDeltaPct/100;if(Number.isFinite(J)&&J>0)R.push(Math.log(J))}if(R.length===0)return null;let x=R.reduce((C,J)=>C+J,0)/R.length;return(Math.exp(x)-1)*100}function q(u,R,x=m){let C=at(u,R,x);return{effectiveTimingPct:C.effectiveTimingPct,compare:(J)=>ut(C,J,x),unmatched(){let J=new Set(u.workloads.map((fe)=>fe.id));return{baseOnly:u.workloads.filter((fe)=>!C.candWorkloads.has(fe.id)),candOnly:R.workloads.filter((fe)=>!J.has(fe.id))}}}}function K(u,R){let x=0,C=0,J=0;for(let fe of u){if(!fe.timing)continue;if(fe.timing.verdict==="regressed")x++;else if(fe.timing.verdict==="improved")C++;else J++}return{matched:u.length,regressed:x,improved:C,unchanged:J,geomeanPct:ct(u),effectiveTimingPct:R,verdict:u.some((fe)=>fe.verdict==="fail")?"fail":"pass"}}function F(u,R,x=m){let C=q(u,R,x),J=[];for(let fe of u.workloads){let ie=C.compare(fe.id);if(ie)J.push(ie)}return{comparisons:J,unmatched:C.unmatched(),summary:K(J,C.effectiveTimingPct)}}function ut(u,R,x){let{baseByPhase:C,candByPhase:J,effectiveTimingPct:fe}=u,ie=C.get(`${R}\x00timing`),ee=J.get(`${R}\x00timing`),he=C.get(`${R}\x00cpu`),pe=J.get(`${R}\x00cpu`),ge=C.get(`${R}\x00heap`),xe=J.get(`${R}\x00heap`),we=u.candWorkloads.get(R),ye=ie?.id??he?.id??ge?.id,Pe=ee?.id??pe?.id??xe?.id??we?.id;if(!ye||!Pe)return;let $e=!1,Me=[];if(u.environmentMismatch)Me.push(u.environmentMismatch);let Ie;if(ie?.timing&&we?.skipped&&!ee?.timing)Ie={medianDeltaPct:0,meanDeltaPct:0,verdict:"unchanged"},Me.push({code:"skipped",message:"Candidate has no timing measurement for this workload (task.skip()); treated as unchanged.",data:{workloadId:R}});else if(ie?.timing&&ee?.timing){let be=ie.timing.samples,Ce=ee.timing.samples,ke=nn(ie.timing.median,ee.timing.median),Re=nn(ie.timing.mean,ee.timing.mean),ve=(Te,We)=>{if(Te>fe)return"regressed";if(We<-fe)return"improved";return"unchanged"};if(be.length<mn||Ce.length<mn){let Te=ve(ke,ke);if(Te==="regressed")$e=!0;Ie={medianDeltaPct:ke,meanDeltaPct:Re,verdict:Te},Me.push({code:"thin-comparison",message:`Only ${be.length} baseline / ${Ce.length} candidate sample(s); falling back to a point-estimate threshold instead of a bootstrap CI and Mann-Whitney test (needs ${mn}+ per side).`,data:{baseSamples:be.length,candSamples:Ce.length}})}else{let Te=yn(be,Ce,{iterations:x.bootstrapIterations}),We=xn(be,Ce),Ee=We.pValue<x.alpha?ve(Te.ci95[0],Te.ci95[1]):"unchanged";if(Ee==="regressed")$e=!0;Ie={medianDeltaPct:ke,meanDeltaPct:Re,ci95:Te.ci95,pValue:We.pValue,seed:Te.seed,verdict:Ee}}}let Oe;if(he?.cpu&&pe?.cpu){let be=new Map(he.cpu.totals.map((Te)=>[he.cpu.frames[Te.frameIx].key,Te])),Ce=new Map(pe.cpu.totals.map((Te)=>[pe.cpu.frames[Te.frameIx].key,Te])),ke=new Map(he.cpu.frames.map((Te)=>[Te.key,Te.name])),Re=new Map(pe.cpu.frames.map((Te)=>[Te.key,Te.name]));Oe=[...new Set([...be.keys(),...Ce.keys()])].map((Te)=>{let We=be.get(Te)?.selfUs??0,Ee=Ce.get(Te)?.selfUs??0;return{frameKey:Te,name:Re.get(Te)??ke.get(Te)??Te,baseSelfUs:We,candSelfUs:Ee,deltaPct:nn(We,Ee)}}).sort((Te,We)=>Math.abs(We.deltaPct)-Math.abs(Te.deltaPct));for(let Te of Oe)if((Te.baseSelfUs>=x.minFrameSelfUs||Te.candSelfUs>=x.minFrameSelfUs)&&Te.deltaPct>x.frameSelfPct)$e=!0}let Se;if(ge?.heap&&xe?.heap){let be=new Map(ge.heap.typeCounts.map((Re)=>[Re.type,Re])),Ce=new Map(xe.heap.typeCounts.map((Re)=>[Re.type,Re]));Se=[...new Set([...be.keys(),...Ce.keys()])].map((Re)=>{let ve=be.get(Re),Te=Ce.get(Re);return{type:Re,baseCount:ve?.count??0,candCount:Te?.count??0,baseBytes:ve?.retainedBytes,candBytes:Te?.retainedBytes,deltaPct:nn(ve?.count??0,Te?.count??0)}}).sort((Re,ve)=>Math.abs(ve.deltaPct)-Math.abs(Re.deltaPct));for(let Re of Se)if(Re.deltaPct>x.heapTypePct)$e=!0}return{id:e("cmp",ye,Pe),baselineMeasurementId:ye,candidateMeasurementId:Pe,timing:Ie,...Me.length>0&&{warnings:Me},frames:Oe,heapTypes:Se,thresholds:{...x,effectiveTimingPct:fe},verdict:$e?"fail":"pass"}}var qe="node_modules/.cache/ostia",lt=".ostia/baselines",dt={warmup:3,outDir:qe,baselineDir:lt,baseline:"main",thresholds:m,workloads:[]};class P extends Error{}var pt={runs:"samples"};function $n(u,R){for(let[x,C]of Object.entries(pt))if(x in u)throw new P(`${R}: "${x}" was renamed to "${C}".`);return{...dt,...u,thresholds:{...m,...u.thresholds??{}}}}async function kn(u){let R=Bun.file(u);if(!await R.exists())return;let x;try{x=await R.json()}catch(C){throw new P(`${u}: ${C instanceof Error?C.message:String(C)}`)}return $n(x,u)}async function Mn(u){let R=u.startsWith("/")?u:`${process.cwd()}/${u}`;if(!await Bun.file(R).exists())return;let x;try{x=await import(R)}catch(C){throw new P(`${u}: ${C instanceof Error?C.message:String(C)}`)}return $n(x.default??{},u)}async function E(u){if(u!==void 0)return u.endsWith(".ts")?Mn(u):kn(u);return await Mn("ostia.config.ts")??kn("ostia.config.json")}function o(u,R){return`${u.baselineDir}/${R??u.baseline}.json`}async function Y(){if(await Bun.file("ostia.config.ts").exists())return"ostia.config.ts";if(await Bun.file("ostia.config.json").exists())return"ostia.config.json";return}var ft=10,gt=3000000000,ht=3;function cn(u){if(u.timeSource)H(u.timeSource);let R=u.warmup??ht,x=u.samples,C=u.minSamples??ft,J=x??C,fe=x!==void 0?0:u.budgetMs!==void 0?u.budgetMs*1e6:gt,ie=u.timeSource!==void 0,ee=u.ignoreExitCodes??[],he=new Set(ee),pe=[],ge=0,xe=0,we=!1,ye;function Pe(){if(we)return!0;if(x!==void 0)return xe>=x;return xe>=J&&ge>=fe}async function $e(Me,Ie){if(u.prepare)await G(u.prepare,{phase:Me,index:Ie},{cwd:u.cwd,env:u.env,timeoutMs:u.timeoutMs,signal:u.signal});return re(u)}return{async warmup(){for(let Me=0;Me<R;Me++){if(u.signal?.aborted)return;await $e("warmup",Me)}},async step(){if(Pe()||u.signal?.aborted)return!1;let Me=await $e("timing",xe);if(u.signal?.aborted)return!1;if(Me.timeSourceNoMatch)ye??=Me.timeSourceMissOutput;if(pe.push({i:xe,wallNs:Me.wallNs,exitCode:Me.exitCode??void 0,userNs:Me.userNs,systemNs:Me.systemNs,maxRssBytes:Me.maxRssBytes,...Me.reportedNs!==void 0&&{reportedNs:Me.reportedNs},...Me.timedOut?{timedOut:!0}:{},...Me.timeSourceNoMatch?{timeSourceNoMatch:!0}:{}}),ge+=Me.wallNs,xe++,Me.exitCode!==null&&Me.exitCode!==0&&!he.has(Me.exitCode))we=!0;return!0},done:Pe,result(){let Me=pe.filter((ke)=>!ke.timedOut&&!ke.timeSourceNoMatch),Ie=Me.map((ke)=>ie?ke.reportedNs:ke.wallNs),Oe=[],Se=pe.filter((ke)=>ke.timedOut).length;if(Se>0)Oe.push({code:"timeout",message:`${Se} of ${pe.length} trial(s) timed out after ${u.timeoutMs}ms.`,data:{timeoutMs:u.timeoutMs,trials:Se}});let be=pe.filter((ke)=>ke.timeSourceNoMatch).length;if(be>0&&u.timeSource){let{pattern:ke}=u.timeSource;Oe.push({code:"time-source-no-match",message:`${be} of ${pe.length} trial(s) didn't match the timeSource pattern.`,data:{pattern:typeof ke==="string"?ke:ke.source,trials:be,...ye!==void 0&&{output:ye}}})}if(Ie.length===0)return{trials:pe,warnings:Oe};let Ce=f(Ie);return Oe.push(...j(Ce,Me.map((ke)=>ke.exitCode),ie?"reported":"subprocess",ee)),{trials:pe,timing:Ce,warnings:Oe}}}}async function un(u){await u.warmup();while(await u.step());}async function ne(u){let R=cn(u);return await un(R),R.result()}function B(u,R=[]){if(!u.timing)return!0;let x=new Set(R);return u.trials.some((C)=>C.exitCode!==void 0&&C.exitCode!==0&&!x.has(C.exitCode))}function tn(u,R){let x={samples:R.samples,minSamples:R.minSamples};for(let[C,J]of Object.entries(x))if(J!==void 0&&(!Number.isFinite(J)||J<1))throw RangeError(`${u}: ${C} must be >= 1, got ${J}`);if(R.budgetMs!==void 0&&!Number.isFinite(R.budgetMs))throw RangeError(`${u}: budgetMs must be finite, got ${R.budgetMs}`)}async function A(u,R){let x=new Set;for(let C of u)for await(let J of new Bun.Glob(C).scan({cwd:R,absolute:!1}))x.add(J);return[...x].sort()}var Rn=new URL("./runner.ts",import.meta.url).pathname;function Z(){return Math.max(1,navigator.hardwareConcurrency||1)}async function X(u,R){return A(u,R)}function bt(u){if(u===void 0)return;return u==="auto"?Z():u}async function W(u,R,x=process.cwd()){return{suites:u.suites.length>0?u.suites:R?.suites?await X(R.suites,x):[],budgetMs:u.budgetMs??R?.budgetMs,samples:u.samples??R?.samples,minSamples:u.minSamples??R?.minSamples,jobs:u.jobs??bt(R?.jobs),gc:u.gc??R?.gc??!1,cpu:u.cpu??R?.cpu??!1,alloc:u.alloc??R?.alloc??!1,filter:u.filter??R?.filter,isolate:u.isolate??R?.isolate??!1,preload:u.preload.length>0?u.preload:R?.preload??[],bunFlags:u.bunFlags.length>0?u.bunFlags:R?.bunFlags??[],outDir:u.outDir??R?.outDir,noiseCheck:u.noiseCheck,timeoutMs:u.timeoutMs??R?.timeoutMs,cwd:x}}async function v(u){tn("bench",u);let x=`${u.outDir??qe}/bench-tmp`,C=u.cwd??process.cwd(),J=Math.max(1,Math.floor(u.jobs??1)),fe={budgetMs:u.budgetMs,samples:u.samples,minSamples:u.minSamples,gc:u.gc,cpu:u.cpu,alloc:u.alloc,noiseCheck:!1},ie=u.noiseCheck===!1?void 0:l(),ee=ie?d(ie):void 0,he=(ye)=>ye.startsWith("/")?ye:`${C}/${ye}`,pe=u.suites.map(he),ge=(u.preload??[]).map(he),xe=u.bunFlags??[],we=async(ye,Pe)=>{let $e=new Set,Me=0,Ie,Oe=async()=>{while(Ie===void 0&&!u.signal?.aborted&&Me<ye.length){let Se=Me++;try{let be=V(u.timeoutMs,u.signal),Ce=Bun.spawn(ye[Se],{cwd:C,stdout:"inherit",stderr:"inherit",stdin:"ignore",...be.spawn});$e.add(Ce);let ke=await Ce.exited;if($e.delete(Ce),u.signal?.aborted)return;if(be.timedOut())throw Error(`Bench suite timed out after ${u.timeoutMs}ms: ${Pe(Se)}`);if(ke!==0)throw Error(`Bench suite failed: ${Pe(Se)} (runner exited ${ke})`)}catch(be){Ie??=be instanceof Error?be:Error(String(be));for(let Ce of $e)Ce.kill()}}};if(await Promise.all(Array.from({length:Math.min(J,ye.length)},Oe)),Ie)throw Ie};try{let ye=pe.map((ve)=>`${x}/${e("bench-plan",ve)}.json`),Pe=pe.map((ve)=>`${x}/${e("bench-primary",ve)}.json`),$e=pe.map((ve,Te)=>["bun",...xe,Rn,ve,Pe[Te],JSON.stringify({...fe,filter:u.filter,isolate:u.isolate,preload:ge,planPath:ye[Te]})]);await we($e,(ve)=>u.suites[ve]);let Me=await Promise.all(ye.map(async(ve)=>{if(!await Bun.file(ve).exists())return[];let{tasks:Te}=await Bun.file(ve).json();return Te})),Ie=await Promise.all(Pe.map(async(ve)=>await Bun.file(ve).exists()?s(ve):void 0)),Oe=[];for(let ve=0;ve<Me.length;ve++)for(let Te of Me[ve])if(Te.isolate)Oe.push({suiteIndex:ve,taskIds:[Te.id]});let Se=Oe.map((ve,Te)=>`${x}/${e("bench-item",pe[ve.suiteIndex],Te)}.json`),be=Oe.map((ve,Te)=>["bun",...xe,Rn,pe[ve.suiteIndex],Se[Te],JSON.stringify({...fe,taskIds:ve.taskIds,preload:ge,markIsolated:!0})]);await we(be,(ve)=>u.suites[Oe[ve].suiteIndex]);let Ce=await Promise.all(Se.map(async(ve)=>await Bun.file(ve).exists()?s(ve):void 0)),ke=[],Re=[];for(let ve=0;ve<Me.length;ve++){let Te=Ie[ve];if(!Te)continue;let We=new Map;for(let Be of Te.measurements){let De=We.get(Be.workloadId)??[];De.push(Be),We.set(Be.workloadId,De)}let Ee=0,Je=new Map;Oe.forEach((Be,De)=>{let Fe=Ce[De];if(Be.suiteIndex===ve&&Fe)Je.set(Be.taskIds[0],Fe)});for(let Be of Me[ve])if(Be.isolate){let De=Je.get(Be.id);if(!De)continue;let Fe=De.workloads[0];ke.push(Fe);for(let Ae of De.measurements)if(Ae.workloadId===Fe.id)Re.push(Ae)}else{let De=Te.workloads[Ee];ke.push(De),Ee++;for(let Fe of We.get(De.id)??[])Re.push(Fe)}}if(ee&&Re.length>0)Re[0].warnings=[...Re[0].warnings,ee];if(u.signal?.aborted&&Re.length>0){let ve=Re[Re.length-1];ve.warnings=[...ve.warnings,{code:"aborted",message:"Run was cancelled before it finished; this document holds whatever suites/tasks had already completed."}]}return r(ke,Re,ie)}finally{await Bun.spawn(["rm","-rf",x]).exited}}function ce(u,R,x=8){if(x<=1)throw RangeError(`range: multiplier must be > 1, got ${x}`);if(u<=0)throw RangeError(`range: start must be > 0, got ${u}`);let C=[];for(let J=u;J<=R;J*=x)C.push(J);if(!C.includes(R))C.push(R);return C}function je(u,R){if(R){let x=u.measurements.find((C)=>C.id===R);return x?.cpu?[x]:[]}return u.measurements.filter((x)=>x.phase==="cpu"&&x.cpu)}function He(u){let R=u.nodes,x=R.length,C=wt(u),J=new Int32Array(x).fill(-1);for(let he=0;he<x;he++)for(let pe of R[he].children){let ge=C(pe);if(ge!==-1)J[ge]=he}let fe=[];for(let he=0;he<x;he++)if(J[he]===-1)fe.push(he);let ie=[],ee=[];for(let he=fe.length-1;he>=0;he--)ee.push(fe[he]);while(ee.length>0){let he=ee.pop();ie.push(he);for(let pe of R[he].children){let ge=C(pe);if(ge!==-1&&J[ge]===he)ee.push(ge)}}return{count:x,indexOf:C,parentIx:J,roots:fe,order:ie}}function wt(u){let R=u.nodes,x=R.length,C=1/0,J=-1/0,fe=!0;for(let ee=0;ee<x;ee++){let he=R[ee].id;if(!Number.isInteger(he)){fe=!1;break}if(he<C)C=he;if(he>J)J=he}if(fe&&x>0&&J-C<x*4+64){let ee=J-C+1,he=new Int32Array(ee).fill(-1);for(let pe=0;pe<x;pe++)he[R[pe].id-C]=pe;return(pe)=>{let ge=pe-C;return ge>=0&&ge<ee?he[ge]:-1}}let ie=new Map;for(let ee=0;ee<x;ee++)ie.set(R[ee].id,ee);return(ee)=>ie.get(ee)??-1}function Cn(u,R){let{count:x,indexOf:C,parentIx:J,order:fe}=R,ie=new Float64Array(x),ee=new Float64Array(x),he=u.samples?.nodeIds??[],pe=u.samples?.timeDeltasUs??[];for(let xe=0;xe<he.length;xe++){let we=C(he[xe]);if(we===-1)continue;ie[we]+=pe[xe]??0,ee[we]+=1}let ge=new Float64Array(x);for(let xe=fe.length-1;xe>=0;xe--){let we=fe[xe];ge[we]+=ie[we];let ye=J[we];if(ye>=0)ge[ye]+=ge[we]}return{selfUs:ie,totalUs:ge,samples:ee}}var vn={name:"collapsed",async render(u,R={}){return{files:je(u,R.measurementId).map((J)=>{let fe=J.cpu,{nodes:ie,frames:ee}=fe,he=He(fe),pe=Array(he.count);for(let Pe of he.order){let $e=ee[ie[Pe].frameIx].name||"(anonymous)",Me=he.parentIx[Pe];pe[Pe]=Me===-1?$e:`${pe[Me]};${$e}`}let ge=new Float64Array(he.count),xe=[],we=fe.samples?.nodeIds??[];for(let Pe=0;Pe<we.length;Pe++){let $e=he.indexOf(we[Pe]);if($e===-1)continue;if(ge[$e]++===0)xe.push($e)}let ye=Array(xe.length);for(let Pe=0;Pe<xe.length;Pe++){let $e=xe[Pe];ye[Pe]=`${pe[$e]} ${ge[$e]}`}return{path:`${J.id}.collapsed.txt`,content:ye.join(`
|
|
3
|
-
`)+(ye.length>0?`
|
|
4
|
-
`:"")}})}}};var Tn={name:"cpuprofile",async render(u,R={}){let x=je(u,R.measurementId),C=[],J=[];for(let fe of x){if(fe.cpu?.origin!=="cpu-prof"&&fe.cpu?.origin!=="inspector"){J.push(`${fe.id} (origin ${fe.cpu?.origin??"unknown"} has no .cpuprofile artifact to pass through)`);continue}let ie=fe.artifacts.find((he)=>he.kind==="cpuprofile");if(!ie){J.push(`${fe.id} (no cpuprofile artifact recorded on this run)`);continue}let ee=Bun.file(ie.path);if(!await ee.exists()){J.push(`${fe.id} (artifact missing on disk: ${ie.path})`);continue}C.push({path:`${fe.id}.cpuprofile`,content:await ee.text()})}if(C.length===0&&J.length>0)return{text:`No .cpuprofile artifacts available:
|
|
5
|
-
${J.map((fe)=>` - ${fe}`).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`};return{files:C}}};var In={name:"json",async render(u){return{text:k(u)}}};var Sn={name:"jsonl",async render(u){let{measurements:R,...x}=u;return{text:`${[T({kind:"document",...x}),...R.map((J)=>T({kind:"measurement",...J}))].join(`
|
|
8
|
-
`)}
|
|
9
|
-
`}}};function rn(u){if(!u?.entry)return;if(u.entry.group!==void 0)return u.entry.group;let R=u.entry.task,x=R.lastIndexOf("/");return x===-1?void 0:R.slice(0,x)}function ze(u){let R=Math.min(...u.map((J)=>J.run.timing.median)),x=new Map;for(let J of u){let fe=rn(J.workload);if(fe===void 0)continue;let ie=x.get(fe);if(ie)ie.push(J);else x.set(fe,[J])}let C=new Map;for(let J of u){let fe=rn(J.workload);if(fe===void 0){C.set(J,R);continue}let ie=x.get(fe)??[J],ee=ie.find((he)=>he.workload?.baseline);C.set(J,ee?ee.run.timing.median:Math.min(...ie.map((he)=>he.run.timing.median)))}return C}function Ge(u){return u.measurements.filter((R)=>R.phase==="timing"&&R.timing!==void 0)}function Ke(u,R){let x=new Set(R.map((C)=>C.workloadId));return u.workloads.filter((C)=>C.skipped&&!x.has(C.id))}function sn(u){for(let R of u.comparisons??[]){let x=R.warnings?.find((C)=>C.code==="environment-mismatch");if(x)return x}return}function Dn(u){return(u/1e6).toFixed(3)}function On(u){if(!u?.params)return"";return` (${Object.entries(u.params).map(([x,C])=>`${x}=${C}`).join(", ")})`}function Ue(u){return te(String(u))}function yt(u){let R;for(let x of u){let C=x?.params?Object.keys(x.params):void 0;if(C?.length!==2)return;if(R===void 0)R=C;else if(C.length!==R.length||C.some((J,fe)=>J!==R[fe]))return}return R}var Nn=10,Fn=10,Wn={name:"markdown",async render(u){let R=new Map(u.workloads.map((ee)=>[ee.id,ee])),x=[];x.push("# Profile Report","");let C=u.git?` \xB7 ${g(u.git)}`:"";if(x.push(`Bun ${u.bunVersion} \xB7 ostia ${u.toolVersion} \xB7 ${u.platform.os}/${u.platform.arch} \xB7 ${u.createdAt}${C}`,""),u.environment)x.push(U(u.environment),"");let J=sn(u);if(J)x.push(`> \u26A0 ${J.message}`,"");let fe=Ge(u),ie=Ke(u,fe);if(fe.length>0||ie.length>0){x.push("## Timing","");let ee=new Map,he=[];for(let xe of fe){let we=R.get(xe.workloadId)?.entry?.group;if(we===void 0){he.push(xe);continue}let ye=ee.get(we);if(ye)ye.push(xe);else ee.set(we,[xe])}let pe=new Map;for(let[xe,we]of ee){let ye=yt(we.map((Pe)=>R.get(Pe.workloadId)));if(ye)pe.set(xe,{keys:ye,runs:we});else he.push(...we)}if(he.length>0||ie.length>0){let xe=fe.map((be)=>({run:be,workload:R.get(be.workloadId)})),we=xe.length>1,ye=we?ze(xe):void 0,Pe=new Map(xe.map((be)=>[be.run.id,ye?.get(be)??be.run.timing.median])),$e=we?" Relative |":"",Me=we?"---|":"",Ie=he.some((be)=>h(be)),Oe=Ie?" User/Sys |":"",Se=Ie?"---|":"";x.push(`| Task | Median | Spread (p75\u2026p99) | Mean \xB1 SD | Range | MAD |${Oe}${$e}`,`|---|---|---|---|---|---|${Se}${Me}`);for(let be of he){let Ce=R.get(be.workloadId),ke=Ue(t(Ce)+On(Ce)),Re=be.timing,ve=S(Re.median),Te=h(be),We=Ie?` ${Te?_(Te):"-"} |`:"",Ee=we?` ${L(Re.median/(Pe.get(be.id)??Re.median),!!Ce?.baseline)} |`:"";x.push(`| ${ke} | ${n(Re.median,ve)} | ${n(Re.p75,ve)}\u2026${n(Re.p99,ve)} | ${n(Re.mean,ve)} \xB1 ${n(Re.stddev,ve)} | ${n(Re.min,ve)}\u2026${n(Re.max,ve)} | ${n(Re.mad,ve)} |${We}${Ee}`)}for(let be of ie){let Ce=Ue(t(be)+On(be)),ke=we?" - |":"",Re=Ie?" - |":"";x.push(`| ${Ce} | - skipped | - | - | - | - |${Re}${ke}`)}x.push("")}for(let[xe,{keys:we,runs:ye}]of pe){let[Pe,$e]=we,Me=[],Ie=[],Oe=new Map;for(let Se of ye){let be=R.get(Se.workloadId).params,Ce=be[Pe],ke=be[$e];if(!Me.includes(Ce))Me.push(Ce);if(!Ie.includes(ke))Ie.push(ke);Oe.set(`${Ce}\x00${ke}`,Se)}x.push(`### ${Ue(xe)} (${Ue(Pe)} \xD7 ${Ue($e)})`,""),x.push(`| ${Ue(Pe)} \\ ${Ue($e)} | ${Ie.map(Ue).join(" | ")} |`,`|---|${Ie.map(()=>"---").join("|")}|`);for(let Se of Me){let be=Ie.map((Ce)=>{let ke=Oe.get(`${Se}\x00${Ce}`);return ke?n(ke.timing.median):"-"});x.push(`| ${Ue(Se)} | ${be.join(" | ")} |`)}x.push("")}let ge=fe.filter((xe)=>xe.warnings.length>0);if(ge.length>0){x.push("### Warnings","");for(let xe of ge){let we=t(R.get(xe.workloadId));for(let ye of xe.warnings)x.push(`- **${we}**: ${ye.message} (\`${ye.code}\`)`)}x.push("")}}for(let ee of u.measurements){if(ee.phase!=="cpu"&&ee.phase!=="heap")continue;let he=t(R.get(ee.workloadId));if(ee.phase==="cpu"){if(x.push(`## CPU capture - ${he}`,""),x.push(`instrumented, diagnostic wall ${Dn(ee.diagnosticWallNs??0)}ms`,""),ee.cpu){x.push(`origin: \`${ee.cpu.origin}\`, interval: ${ee.cpu.samplingIntervalUs}\xB5s`,""),x.push("| Self % | Self (ms) | Total (ms) | Frame |","|---|---|---|---|");let pe=ee.cpu.totals.reduce((ge,xe)=>ge+xe.selfUs,0)||1;for(let ge of ee.cpu.totals.slice(0,Nn)){let xe=ee.cpu.frames[ge.frameIx],we=(ge.selfUs/pe*100).toFixed(1);x.push(`| ${we}% | ${(ge.selfUs/1000).toFixed(2)} | ${(ge.totalUs/1000).toFixed(2)} | ${Ue(xe?.name||"(anonymous)")} |`)}if(x.push(""),ee.jit){let ge=ee.jit.tiers;x.push(`JIT tiers: LLInt ${ge.llint} \xB7 Baseline ${ge.baseline} \xB7 DFG ${ge.dfg} \xB7 FTL ${ge.ftl}`,"")}}}else if(x.push(`## Heap snapshot - ${he}`,""),x.push(`instrumented, diagnostic wall ${Dn(ee.diagnosticWallNs??0)}ms`,""),ee.heap){x.push(`${ee.heap.objectCount??"?"} objects, ${((ee.heap.heapSizeBytes??0)/1e6).toFixed(2)}MB`,""),x.push("| Count | Type |","|---|---|");for(let pe of ee.heap.typeCounts.slice(0,Fn))x.push(`| ${pe.count} | ${Ue(pe.type)} |`);x.push("")}for(let pe of ee.artifacts)x.push(`- artifact: \`${pe.path}\``);for(let pe of ee.warnings)x.push(`- ! ${pe.message} (\`${pe.code}\`)`);if(ee.artifacts.length>0||ee.warnings.length>0)x.push("")}if(u.comparisons&&u.comparisons.length>0){x.push("## Comparisons","");for(let ee of u.comparisons){let he=u.measurements.find((ge)=>ge.id===ee.candidateMeasurementId),pe=t(he?R.get(he.workloadId):R.get(ee.candidateMeasurementId));if(x.push(`### ${ee.verdict==="pass"?"\u2713":"\u2717"} ${pe}`,""),ee.timing){let ge=ee.timing.medianDeltaPct>0?"+":"",xe=ee.timing.verdict==="unchanged"&&ee.timing.pValue!==void 0&&ee.timing.pValue>=ee.thresholds.alpha?"~":"",we=[];if(he?.timing)we.push(`n=${he.timing.samples.length}`);if(ee.timing.ci95)we.push(`95% CI [${ee.timing.ci95[0]>0?"+":""}${ee.timing.ci95[0].toFixed(1)}%, ${ee.timing.ci95[1]>0?"+":""}${ee.timing.ci95[1].toFixed(1)}%]`);if(ee.timing.pValue!==void 0)we.push(`p=${ee.timing.pValue.toFixed(4)}`);we.push(`threshold ${ee.thresholds.effectiveTimingPct.toFixed(1)}%`),x.push(`- timing: ${xe}${ge}${ee.timing.medianDeltaPct.toFixed(1)}% median, ${we.join(", ")} (**${ee.timing.verdict}**)`)}for(let ge of ee.frames?.slice(0,Nn)??[]){if(Math.abs(ge.deltaPct)<M)continue;let xe=ge.deltaPct>0?"+":"";x.push(`- frame \`${Ue(ge.name)}\`: ${xe}${ge.deltaPct.toFixed(1)}% self-time (${(ge.baseSelfUs/1000).toFixed(2)}ms \u2192 ${(ge.candSelfUs/1000).toFixed(2)}ms)`)}for(let ge of ee.heapTypes?.slice(0,Fn)??[]){if(Math.abs(ge.deltaPct)<M)continue;let xe=ge.deltaPct>0?"+":"";x.push(`- heap \`${Ue(ge.type)}\`: ${xe}${ge.deltaPct.toFixed(1)}% count (${ge.baseCount} \u2192 ${ge.candCount})`)}for(let ge of ee.warnings??[]){if(ge.code==="environment-mismatch")continue;x.push(`- ! ${ge.message} (\`${ge.code}\`)`)}x.push("")}}return{text:x.join(`
|
|
10
|
-
`)}}};var xt=15;function ln(u){return`n${u}`}function Pt(u,R,x){return`${(u||"(anonymous)").replace(/"/g,"'")} (self ${(R/1000).toFixed(2)}ms, total ${(x/1000).toFixed(2)}ms)`}function kt(u,R,x,C){let J=[];if(C<=0)return J;for(let fe=0;fe<R;fe++){if(fe===x)continue;let ie=u[fe];if(J.length===C&&ie<=u[J[C-1]])continue;let ee=J.length;while(ee>0&&u[J[ee-1]]<ie)ee--;if(J.splice(ee,0,fe),J.length>C)J.pop()}return J}var En={name:"mermaid",async render(u,R={}){let x=R.topN??xt;return{files:je(u,R.measurementId).map((fe)=>{let ie=fe.cpu,{nodes:ee,frames:he}=ie,pe=He(ie),{selfUs:ge,totalUs:xe}=Cn(ie,pe),{parentIx:we}=pe,ye=pe.roots[0]??-1,Pe=kt(ge,pe.count,ye,x),$e=new Set(ye!==-1?[ye]:[]),Me=[];for(let Oe of Pe){Me.length=0;for(let Se=Oe;Se!==-1;Se=we[Se])Me.push(Se);for(let Se=Me.length-1;Se>=0;Se--)$e.add(Me[Se])}let Ie=["graph TD"];for(let Oe of $e){let Se=ee[Oe].id;Ie.push(` ${ln(Se)}["${Pt(he[ee[Oe].frameIx].name,ge[Oe],xe[Oe])}"]`)}for(let Oe of $e){let Se=we[Oe];if(Se!==-1&&$e.has(Se))Ie.push(` ${ln(ee[Se].id)} --> ${ln(ee[Oe].id)}`)}return{path:`${fe.id}.mermaid.md`,content:`${Ie.join(`
|
|
11
|
-
`)}
|
|
12
|
-
`}})}}};var p=1;function Ne(u){return Number.isFinite(u)?Number(u.toPrecision(6)):u}function dn(u,R){return u?.entry?.task??u?.label??u?.command?.join(" ")??R}function Un(u,R){if(R?.entry?.group!==void 0)u.group=R.entry.group;if(R?.description!==void 0)u.description=R.description;if(R?.groupDescription!==void 0)u.groupDescription=R.groupDescription;if(R?.params!==void 0)u.params=R.params}function Bn(u){if(!u?.timing)return;let R={medianPct:Ne(u.timing.medianDeltaPct),meanPct:Ne(u.timing.meanDeltaPct),verdict:u.timing.verdict,pass:u.verdict==="pass",effectiveTimingPct:Ne(u.thresholds.effectiveTimingPct),matched:!0};if(u.timing.ci95)R.ci95=[Ne(u.timing.ci95[0]),Ne(u.timing.ci95[1])];if(u.timing.pValue!==void 0)R.pValue=Ne(u.timing.pValue);return R}function Mt(u,R,x,C){let J={event:"run",protocolVersion:p,schemaVersion:u.schemaVersion,workloadId:R.id,task:dn(R,R.id),skipped:!0,batch:1,warnings:(x?.warnings??[]).map((ie)=>ie.data?{code:ie.code,data:ie.data}:{code:ie.code})};if(Un(J,R),C!==void 0)J.noiseFloorPct=Ne(C);let fe=Bn(x);if(fe)J.delta=fe;return J}function $t(u){let R=new Map(u.workloads.map((pe)=>[pe.id,pe])),x=u.environment?.noise.floorPct,C=Ge(u).map((pe)=>({run:pe,workload:R.get(pe.workloadId)})),J=C.length>1?ze(C):void 0,fe=new Map((u.comparisons??[]).map((pe)=>[pe.candidateMeasurementId,pe])),ie=new Map;for(let pe of u.measurements){if(pe.phase!=="cpu"||pe.warnings.length===0)continue;let ge=ie.get(pe.workloadId)??[];ie.set(pe.workloadId,[...ge,...pe.warnings])}let ee=Ke(u,C.map((pe)=>pe.run)).map((pe)=>Mt(u,pe,fe.get(pe.id),x));return[...C.map((pe)=>{let{run:ge,workload:xe}=pe,we=ge.timing,ye=fe.get(ge.id),Pe={event:"run",protocolVersion:p,schemaVersion:u.schemaVersion,workloadId:ge.workloadId,task:dn(xe,ge.workloadId),unit:"ns",samples:we.samples.length,batch:we.batch??1,mean:Ne(we.mean),median:Ne(we.median),stddev:Ne(we.stddev),stddevPct:Ne(we.mean===0?0:we.stddev/we.mean*100),min:Ne(we.min),max:Ne(we.max),warnings:[...ge.warnings,...ie.get(ge.workloadId)??[],...ye?.warnings??[]].map((Ie)=>Ie.data?{code:Ie.code,data:Ie.data}:{code:Ie.code})};Pe.p75=Ne(we.p75),Pe.p99=Ne(we.p99),Pe.mad=Ne(we.mad);let $e=h(ge);if($e)Pe.userNs=Ne($e.userNs),Pe.systemNs=Ne($e.systemNs);if(Un(Pe,xe),J)Pe.relative=Ne(we.median/(J.get(pe)??we.median));if(xe?.baseline)Pe.baseline=!0;if(x!==void 0)Pe.noiseFloorPct=Ne(x);let Me=Bn(ye);if(Me)Pe.delta=Me;return Pe}),...ee]}function Rt(u){if(!u.unmatched)return[];let R=(x,C)=>({event:"unmatched",protocolVersion:p,workloadId:x.id,task:dn(x,x.id),side:C});return[...u.unmatched.baseOnly.map((x)=>R(x,"base")),...u.unmatched.candOnly.map((x)=>R(x,"cand"))]}function Ct(u,R){let x=u.comparisonSummary,C=(R.unmatched?.baseOnly.length??0)+(R.unmatched?.candOnly.length??0),J={event:"summary",protocolVersion:p,command:R.command,matched:x?.matched??0,regressed:x?.regressed??0,improved:x?.improved??0,unchanged:x?.unchanged??0,unmatched:C,geomeanPct:x?.geomeanPct!==void 0?x.geomeanPct:null,effectiveTimingPct:Ne(x?.effectiveTimingPct??0),verdict:R.exitCode===0?"pass":"fail",exitCode:R.exitCode};if(R.command==="ci"){if(J.cached=R.cached??0,J.executed=R.executed??0,J.failed=R.failed??0,J.missingBaseline=R.missingBaseline??0,R.baseline)J.baseline=R.baseline}if(u.environment)J.noiseFloorPct=Ne(u.environment.noise.floorPct);if(R.baseGit||R.candGit)J.git={...R.baseGit&&{base:R.baseGit},...R.candGit&&{cand:R.candGit}};if(R.exportedTo)J.exportedTo=R.exportedTo;return J}var An={name:"minimal",async render(u,R={}){let x=[...$t(u)];if(R.protocol)x.push(...Rt(R.protocol)),x.push(Ct(u,R.protocol));let C=x.map((J)=>JSON.stringify(J));return{text:C.length>0?`${C.join(`
|
|
13
|
-
`)}
|
|
14
|
-
`:""}}};var vt="https://www.speedscope.app/file-format-schema.json";function Ln(u){return u?.label??u?.command?.join(" ")??u?.entry?.task??"profile"}var _n={name:"speedscope",async render(u,R={}){let x=je(u,R.measurementId),C=new Map(u.workloads.map((fe)=>[fe.id,fe]));return{files:x.map((fe)=>{let ie=fe.cpu,{nodes:ee}=ie,he=He(ie),pe=ie.samples?.nodeIds??[],ge=ie.samples?.timeDeltasUs??[],xe=Array(he.count);for(let $e of he.order){let Me=he.parentIx[$e],Ie=ee[$e].frameIx;xe[$e]=Me===-1?[Ie]:[...xe[Me],Ie]}let we=Array(pe.length);for(let $e=0;$e<pe.length;$e++){let Me=he.indexOf(pe[$e]);we[$e]=Me===-1?[]:xe[Me]}let ye=0;for(let $e=0;$e<ge.length;$e++)ye+=ge[$e];let Pe={$schema:vt,exporter:"ostia",name:Ln(C.get(fe.workloadId)),activeProfileIndex:0,shared:{frames:ie.frames.map(($e)=>({name:$e.name||"(anonymous)",file:$e.url,line:$e.line!==void 0?$e.line+1:void 0}))},profiles:[{type:"sampled",name:Ln(C.get(fe.workloadId)),unit:"microseconds",startValue:0,endValue:ye,samples:we,weights:ge}]};return{path:`${fe.id}.speedscope.json`,content:`${JSON.stringify(Pe,null,2)}
|
|
15
|
-
`}})}}};function Tt(u){return(u/1e6).toFixed(3)}function It(u){if(u<1024)return`${u.toFixed(0)}B`;if(u<1048576)return`${(u/1024).toFixed(2)}KB`;return`${(u/1048576).toFixed(2)}MB`}var Vn={name:"table",async render(u){let R=Ge(u),x=new Map(u.workloads.map((De)=>[De.id,De])),C=u.environment?[U(u.environment),""]:[],J=Ke(u,R);if(R.length===0&&J.length===0){let De=jn(u,x);return{text:De.length>0?`${[...C,...De].join(`
|
|
16
|
-
`)}
|
|
17
|
-
`:`(no timing runs)
|
|
18
|
-
`}}let fe=new Map(R.map((De)=>[De.workloadId,De])),ie=[],ee=[];for(let De of u.workloads){let Fe=fe.get(De.id),Ae=t(De);if(Fe){let Ve={kind:"measured",run:Fe,workload:De,label:Ae};ie.push(Ve),ee.push(Ve)}else if(De.skipped)ie.push({kind:"skipped",workload:De,label:Ae})}let he=new Map(u.measurements.filter((De)=>De.phase==="memstats"&&De.memory?.bytesPerOp!==void 0).map((De)=>[De.workloadId,De.memory.bytesPerOp])),pe=he.size>0,ge=new Map(ee.map((De)=>[De,h(De.run)])),xe=[...ge.values()].some(Boolean),we=ee.length>1,ye=ze(ee),Pe=new Map,$e=new Map,Me;for(let De of ie){let Fe=rn(De.workload);if(Fe!==Me){if(Fe!==void 0)$e.set(De,Fe);Me=Fe}Pe.set(De,Fe!==void 0?" ":"")}let Ie=Math.max(4,...ie.map((De)=>Pe.get(De).length+De.label.length)),Oe=10,Se=18,be=18,Ce=10,ke=18,Re=[...C],ve=pe?` ${"Alloc/op".padEnd(Ce)}`:"",Te=xe?` ${"User/Sys".padEnd(ke)}`:"",We=`${"Task".padEnd(Ie)} ${"Median".padEnd(Oe)} ${"Spread".padEnd(Se)} ${"Range".padEnd(be)}${Te}${ve}${we?" Relative":""}`;Re.push(We),Re.push("-".repeat(We.length));let Ee=[];for(let De of ie){let Fe=$e.get(De);if(Fe!==void 0)Re.push(`${Fe}:`);let Ae=Pe.get(De);if(De.kind==="skipped"){Re.push(`${(Ae+De.label).padEnd(Ie)} - skipped`);continue}let{run:Ve,label:Jn,workload:on}=De,_e=Ve.timing,Ye=S(_e.median),Yn=n(_e.median,Ye),qn=`${n(_e.p75,Ye)}\u2026${n(_e.p99,Ye)}`,Qn=`${n(_e.min,Ye)}\u2026${n(_e.max,Ye)}`,Qe=`${(Ae+Jn).padEnd(Ie)} ${Yn.padEnd(Oe)} ${qn.padEnd(Se)} ${Qn.padEnd(be)}`;if(xe){let Le=ge.get(De);Qe+=` ${(Le?_(Le):"").padEnd(ke)}`}if(pe){let Le=on?he.get(on.id):void 0,Xn=Le!==void 0?It(Le):"";Qe+=` ${Xn.padEnd(Ce)}`}if(we){let Le=_e.median/(ye.get(De)??_e.median);Qe+=` ${L(Le,!!on?.baseline)}`}if(Re.push(Qe),Ve.warnings.length>0)Re.push(`${" ".repeat(Ae.length)} ! ${Ve.warnings.map((Le)=>Le.code).join(", ")}`),Ee.push(De)}if(Ee.length>0){Re.push(""),Re.push("Warnings:");for(let De of Ee)for(let Fe of De.run.warnings)Re.push(` ${De.label}: ${Fe.message}`)}let Je=St(u,x);if(Je.length>0)Re.push(""),Re.push(...Je);let Be=jn(u,x);if(Be.length>0)Re.push(""),Re.push(...Be);return{text:`${Re.map((De)=>De.trimEnd()).join(`
|
|
19
|
-
`)}
|
|
20
|
-
`}}};function jn(u,R){if(!u.comparisons||u.comparisons.length===0)return[];let x=[],C=new Map(u.measurements.map((ie)=>[ie.id,ie])),J=sn(u);if(J)x.push(`\u26A0 ${J.message}`,"");let fe=[];for(let ie of u.comparisons){let ee=C.get(ie.candidateMeasurementId),he=R.get(ee?.workloadId??ie.candidateMeasurementId),pe=he?t(he):ie.candidateMeasurementId,ge=ie.verdict==="pass"?"\u2713":"\u2717";if(x.push(`${ge} ${pe}`),ie.timing){let we=(ye)=>`${ye>=0?"+":""}${ye.toFixed(1)}%`;if(ie.timing.ci95&&ie.timing.pValue!==void 0){let ye=ie.timing.pValue<0.001?"p<0.001":`p=${ie.timing.pValue.toFixed(3)}`;x.push(` timing: ${we(ie.timing.medianDeltaPct)} median, 95% CI [${we(ie.timing.ci95[0])}, ${we(ie.timing.ci95[1])}], ${ye} (${ie.timing.verdict})`)}else x.push(` timing: ${we(ie.timing.medianDeltaPct)} median (${ie.timing.verdict})`)}if(ie.frames)for(let we of ie.frames.slice(0,Hn)){if(Math.abs(we.deltaPct)<M)continue;let ye=we.deltaPct>0?"+":"";x.push(` frame ${we.name}: ${ye}${we.deltaPct.toFixed(1)}% self-time (${(we.baseSelfUs/1000).toFixed(2)}ms -> ${(we.candSelfUs/1000).toFixed(2)}ms)`)}if(ie.heapTypes)for(let we of ie.heapTypes.slice(0,zn)){if(Math.abs(we.deltaPct)<M)continue;let ye=we.deltaPct>0?"+":"";x.push(` heap ${we.type}: ${ye}${we.deltaPct.toFixed(1)}% count (${we.baseCount} -> ${we.candCount})`)}let xe=(ie.warnings??[]).filter((we)=>we.code!=="environment-mismatch");if(xe.length>0){x.push(` ! ${xe.map((we)=>we.code).join(", ")}`);for(let we of xe)fe.push({label:pe,message:we.message})}}if(fe.length>0){x.push("","Comparison warnings:");for(let ie of fe)x.push(` ${ie.label}: ${ie.message}`)}return x}var Hn=5,zn=5;function St(u,R){let x=[];for(let C of u.measurements){if(C.phase!=="cpu"&&C.phase!=="heap")continue;let J=R.get(C.workloadId),fe=J?t(J):C.workloadId;if(C.phase==="cpu")if(C.cpu){x.push(`CPU capture - ${fe} (instrumented, ${C.cpu.samplingIntervalUs}\xB5s interval, diagnostic wall ${Tt(C.diagnosticWallNs??0)}ms)`);let ie=C.cpu.totals.reduce((ee,he)=>ee+he.selfUs,0)||1;for(let ee of C.cpu.totals.slice(0,Hn)){let he=C.cpu.frames[ee.frameIx],pe=(ee.selfUs/ie*100).toFixed(1);x.push(` ${pe.padStart(5)}% ${(ee.selfUs/1000).toFixed(2).padStart(8)}ms self ${he?.name??"?"}`)}}else x.push(`CPU capture - ${fe} (instrumented, no evidence captured)`);else if(C.heap){let ie=((C.heap.heapSizeBytes??0)/1e6).toFixed(2);x.push(`Heap snapshot - ${fe} (instrumented, ${C.heap.objectCount??"?"} objects, ${ie}MB)`);for(let ee of C.heap.typeCounts.slice(0,zn))x.push(` ${String(ee.count).padStart(6)} ${ee.type}`)}else x.push(`Heap snapshot - ${fe} (instrumented, no evidence captured)`);for(let ie of C.artifacts)x.push(` artifact: ${ie.path}`);for(let ie of C.warnings)x.push(` ! ${ie.message}`)}return x}var i={table:Vn,json:In,markdown:Wn,jsonl:Sn,minimal:An,collapsed:vn,mermaid:En,speedscope:_n,cpuprofile:Tn};async function ue(u={}){let R=O();if(R.length===0)throw Error("run(): no tasks registered - call group()/task() before run() in the same file.");let x=Bun.main,C;try{C=D(R,u.filter,x)}catch(fe){throw Error(`run(): ${fe.message}`)}let J=await N(x,C,u);if(!u.quiet){let fe=u.format??"table",{text:ie}=await i[fe].render(J,{});if(ie)process.stdout.write(ie)}return J}function me(u,R){let x=Object.keys(u),C=(J,fe)=>{if(J===x.length){ae(fe,()=>R(fe));return}let ie=x[J];for(let ee of u[ie])C(J+1,{...fe,[ie]:ee})};C(0,{})}function le(u){return u}var pn=1000;async function Q(u){if(tn("time",u),u.warmup!==void 0&&(!Number.isFinite(u.warmup)||u.warmup<0))throw RangeError(`time: warmup must be >= 0, got ${u.warmup}`);let R=c({samples:u.samples??null,budgetMs:u.budgetMs??null,minSamples:u.minSamples??null,warmup:u.warmup??null,cpu:u.cpu??!1,heap:u.heap??!1,cpuIntervalUs:u.cpuIntervalUs??pn}),C=`${u.outDir??qe}/artifacts`,J=u.noiseCheck===!1?void 0:l(),fe=J?d(J):void 0,ie=[],ee=[],he=u.commands.map((ye)=>{let Pe=typeof ye==="string"||Array.isArray(ye)?{command:ye}:ye,$e=Array.isArray(Pe.command)?Pe.command:b(Pe.command),Me=Pe.prepare??u.prepare,Ie=Pe.timeSource??u.timeSource,Oe=Pe.timeoutMs??u.timeoutMs,Se=Pe.ignoreExitCodes??u.ignoreExitCodes,be=I($e,Pe.label??(Array.isArray(Pe.command)?void 0:Pe.command),{prepare:Me,timeSource:Ie});return{argv:$e,workload:be,prepare:Me,timeSource:Ie,timeoutMs:Oe,ignoreExitCodes:Se}}),pe=(u.interleave??!0)&&he.length>1,ge=(ye)=>({argv:ye.argv,cwd:u.cwd,env:u.env,samples:u.samples,budgetMs:u.budgetMs,minSamples:u.minSamples,warmup:u.warmup,prepare:ye.prepare,timeSource:ye.timeSource,timeoutMs:ye.timeoutMs,ignoreExitCodes:ye.ignoreExitCodes,signal:u.signal}),xe=he.map((ye)=>cn(ge(ye))),we=async(ye)=>{let{argv:Pe,workload:$e,prepare:Me}=he[ye];ie.push($e);let Ie=xe[ye].result(),Oe=w({workload:$e,configFingerprint:R,trials:Ie.trials,timing:Ie.timing,warnings:fe&&ee.length===0?[...Ie.warnings,fe]:Ie.warnings,interleaved:pe?!0:void 0});if(ee.push(Oe),!u.signal?.aborted)ee.push(...await Dt({workload:$e,argv:Pe,timingMeasurementId:Oe.id,cfgFp:R,opts:u,artifactDir:C,prepare:Me}))};if(pe){for(let Pe of xe)await Pe.warmup();let ye=!0;while(ye){ye=!1;for(let Pe of xe)if(await Pe.step())ye=!0}for(let Pe=0;Pe<he.length;Pe++)await we(Pe)}else for(let ye=0;ye<he.length;ye++)await un(xe[ye]),await we(ye);if(u.signal?.aborted&&ee.length>0){let ye=ee[ee.length-1];ye.warnings=[...ye.warnings,Kn()]}return r(ie,ee,J)}function Kn(){return{code:"aborted",message:"Run was cancelled before it finished; this document holds whatever measurements had already completed."}}async function Dt({workload:u,argv:R,timingMeasurementId:x,cfgFp:C,opts:J,artifactDir:fe,prepare:ie}){let ee=[],he=async(pe)=>{if(ie)await G(ie,{phase:pe,index:0},{cwd:J.cwd,env:J.env})};if(J.cpu){await he("cpu");let pe=`${x}-cpu.cpuprofile`,ge=await fn({argv:R,cwd:J.cwd,env:J.env,artifactDir:fe,fileName:pe,intervalUs:J.cpuIntervalUs??pn});ee.push(await Gn({workload:u,phase:"cpu",configFingerprint:C,diagnosticWallNs:ge.diagnosticWallNs,exitCode:ge.exitCode,cpu:ge.cpu,artifactPath:ge.artifactPath,artifactKind:"cpuprofile",warnings:ge.warnings}))}if(J.heap){await he("heap");let pe=`${x}-heap.heapsnapshot`,ge=await hn({argv:R,cwd:J.cwd,env:J.env,artifactDir:fe,fileName:pe});ee.push(await Gn({workload:u,phase:"heap",configFingerprint:C,diagnosticWallNs:ge.diagnosticWallNs,exitCode:ge.exitCode,heap:ge.heap,artifactPath:ge.artifactPath,artifactKind:"heapsnapshot",warnings:ge.warnings}))}return ee}async function Gn(u){let R=`${u.workload.id}-${u.phase}-${u.configFingerprint}`,x=u.artifactPath?[await oe(R,u.artifactKind,u.artifactPath)]:[];return y({workload:u.workload,phase:u.phase,configFingerprint:u.configFingerprint,diagnosticWallNs:u.diagnosticWallNs,exitCode:u.exitCode,cpu:u.cpu,heap:u.heap,warnings:u.warnings,artifacts:x})}async function de(u,R={}){let x=se(u),C=c({intervalUs:R.intervalUs??pn,origin:R.origin??"inspector"}),J=(ee)=>ee.samples?.nodeIds.length===0?[{code:"empty-profile",message:"In-process capture produced zero samples."}]:[];if(R.signal?.aborted){let ee=Bun.nanoseconds(),he=await u(),pe=y({workload:x,phase:"cpu",configFingerprint:C,diagnosticWallNs:Bun.nanoseconds()-ee,warnings:[Kn()],artifacts:[]});return{result:he,measurement:pe,document:r([x],[pe])}}let fe=R.origin==="jsc"?await z(u,R):{...await bn(u,R),jit:void 0},ie=y({workload:x,phase:"cpu",configFingerprint:C,diagnosticWallNs:fe.diagnosticWallNs,cpu:fe.cpu,jit:fe.jit,warnings:J(fe.cpu),artifacts:[]});return{result:fe.result,measurement:ie,document:r([x],[ie])}}
|
|
21
|
-
export{m,q,K,F,P,E,o,Y,A,ne,B,Z,X,W,v,ce,p,i,ue,me,le,Q,de};
|
package/chunk-n02qf2mf.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
function f(o){if(o.length===0)throw Error("computeTimingStats: samples must be non-empty");let i=o.length,m=an(o),p=0;for(let P=0;P<i;P++)p+=o[P];let v=p/i,A=a(m,0.5),E=0;for(let P=0;P<i;P++){let K=o[P]-v;E+=K*K}let F=Math.sqrt(E/i),W=m[0],Y=m[i-1],q=a(m,0.25),B=a(m,0.75),ue=B-q,Z=q-1.5*ue,de=B+1.5*ue,ce=q-3*ue,Q=B+3*ue,me=0,le=0;for(let P=0;P<i;P++){let K=o[P];if(K<ce||K>Q)le++;else if(K<Z||K>de)me++}let we=a(m,0.99),Te=new Float64Array(i);for(let P=0;P<i;P++)Te[P]=Math.abs(o[P]-A);Te.sort();let ye=a(Te,0.5);return{unit:"ns",samples:o,mean:v,median:A,stddev:F,min:W,max:Y,outliers:{mild:me,severe:le},p25:q,p75:B,p99:we,mad:ye}}function an(o){let i=new Float64Array(o.length);return i.set(o),i.sort(),i}function a(o,i){let m=o.length;if(m===1)return o[0];let p=i*(m-1),v=Math.floor(p),A=Math.ceil(p);if(v===A)return o[v];let E=p-v;return o[v]*(1-E)+o[A]*E}var un=5000000;function j(o,i,m="subprocess",p=[]){let v=[],A=o.samples[0];if(A!==void 0){let W=o.p75-o.p25;if(A>o.median+3*W&&A>2*o.median&&W>0)v.push({code:"slow-first-run",message:`First run took ${n(A)}, much slower than the median ${n(o.median)}. Consider more warmup.`,data:{firstNs:A,medianNs:o.median}})}if(m!=="inprocess"&&o.outliers.mild+o.outliers.severe>0)v.push({code:"outliers-detected",message:`${o.outliers.mild+o.outliers.severe} outlier(s) detected (${o.outliers.severe} severe, ${o.outliers.mild} mild).`,data:o.outliers});if(m==="subprocess"&&o.median<un)v.push({code:"fast-command",message:`Median run time (${(o.median/1e6).toFixed(3)}ms) is very fast; results may be dominated by spawn overhead.`,data:{medianNs:o.median}});let E=new Set(p),F=i.filter((W)=>W!==void 0&&W!==0&&!E.has(W));if(F.length>0)v.push({code:"nonzero-exit",message:`${F.length} of ${i.length} trial(s) exited non-zero.`,data:{exitCodes:F}});return v}var M=0.5,cn={ns:1,\u{b5}s:1000,ms:1e6,s:1e9};function S(o){let i=Math.abs(o);if(i>=1e9)return"s";if(i>=1e6)return"ms";if(i>=1000)return"\xB5s";return"ns"}function ln(o){let i=Math.floor(Math.log10(Math.max(Math.abs(o),1)))+1;return Math.max(1,3-i)}function n(o,i=S(o)){let m=o/cn[i];return`${m.toFixed(ln(m))} ${i}`}function U(o){return`${o.cpuModel} \xB7 ${o.cores} cores \xB7 load ${o.loadAvg1.toFixed(1)} \xB7 noise floor ${o.noise.floorPct.toFixed(1)}%`}function g(o){return`${o.sha} (${o.branch}${o.dirty?", dirty":""})`}function t(o){return o?.label??o?.command?.join(" ")??o?.entry?.task??o?.id??"unknown"}function L(o,i){if(o===1)return i?"1.00\xD7 (baseline)":"1.00\xD7";if(o>1)return`${o.toFixed(2)}\xD7 slower`;return`${(1/o).toFixed(2)}\xD7 faster`}function te(o){return o.replace(/\|/g,"\\|").replace(/</g,"<").replace(/>/g,">").replace(/`/g,"\\`").replace(/\r\n|\r|\n/g,"<br>")}function h(o){let i=o.trials.filter((p)=>!p.timedOut&&!p.timeSourceNoMatch&&p.userNs!==void 0&&p.systemNs!==void 0);if(i.length===0)return;let m=(p)=>a(Float64Array.from(p).sort(),0.5);return{userNs:m(i.map((p)=>p.userNs)),systemNs:m(i.map((p)=>p.systemNs))}}function _(o){return`${n(o.userNs)}/${n(o.systemNs)}`}class Ie extends Error{}function H(o){if(typeof o.pattern==="string")return;let{flags:i}=o.pattern;if(i.includes("g")||i.includes("y")||i.includes("d"))throw RangeError("timeSource pattern must not use the g or y flag")}function mn(...o){let i=o.filter((m)=>m!==void 0);if(i.length===0)return;if(i.length===1)return i[0];return AbortSignal.any(i)}var pn={ns:1,us:1000,ms:1e6,s:1e9};function V(o,i){let m=o!==void 0?AbortSignal.timeout(o):void 0,p=mn(m,i);return{spawn:p?{signal:p,killSignal:"SIGKILL"}:{},timedOut:()=>m?.aborted??!1}}async function re(o){let i=o.timeSource!==void 0,m=Bun.nanoseconds(),p=V(o.timeoutMs,o.signal),v=Bun.spawn(o.argv,{cwd:o.cwd,env:o.env,stdout:i?"pipe":"ignore",stderr:i?"pipe":"ignore",stdin:"ignore",...p.spawn}),A=i?Promise.all([new Response(v.stdout).text(),new Response(v.stderr).text()]):void 0,E=await v.exited,F=Bun.nanoseconds(),W=v.resourceUsage?.(),Y=p.timedOut(),q={wallNs:F-m,exitCode:Y?null:E,userNs:W?Number(W.cpuTime.user)*1000:void 0,systemNs:W?Number(W.cpuTime.system)*1000:void 0,maxRssBytes:W?.maxRSS,...Y?{timedOut:!0}:{}};if(A){let[B,ue]=await A;if(o.timeSource&&!Y)try{q.reportedNs=dn(o.timeSource,B,ue,o.argv)}catch(Z){if(!(Z instanceof Ie))throw Z;q.timeSourceNoMatch=!0,q.timeSourceMissOutput=fn(B,ue)}}return q}function dn(o,i,m,p=[]){let v=typeof o.pattern==="string"?new RegExp(o.pattern):o.pattern,A=o.group??1,E=v.exec(i)??v.exec(m),F=p.length>0?` for "${p.join(" ")}"`:"";if(!E)throw new Ie(`timeSource pattern ${v} did not match the output${F}. Output was:
|
|
3
|
-
${Ce(i,m)}`);let W=E[A];if(W===void 0)throw Error(`timeSource pattern ${v} matched${F} but has no capture group ${A} (matched text: "${E[0]}").`);let Y=Number(W);if(!Number.isFinite(Y))throw Error(`timeSource pattern ${v} group ${A} captured "${W}"${F}, which is not a number.`);return Y*pn[o.unit??"ms"]}function Ce(o,i){let p=(A)=>A.length>800?`${A.slice(0,800)}\u2026(${A.length-800} more)`:A,v=[];if(o.trim())v.push(`--- stdout ---
|
|
4
|
-
${p(o.trimEnd())}`);if(i.trim())v.push(`--- stderr ---
|
|
5
|
-
${p(i.trimEnd())}`);return v.length>0?v.join(`
|
|
6
|
-
`):"(empty)"}var Ne=2048;function fn(o,i){let m=Ce(o,i);if(Buffer.byteLength(m,"utf8")<=Ne)return m;let p=m.slice(0,Ne);while(Buffer.byteLength(p,"utf8")>Ne)p=p.slice(0,-1);return`${p}\u2026`}var gn=1048576,bn=(o)=>`
|
|
7
|
-
\u2026(${o} bytes elided)\u2026
|
|
8
|
-
`;async function hn(o,i=gn){let m=Math.floor(i/2),p=o.getReader(),v=[],A=0,E=[],F=0,W=0;try{for(;;){let{done:Z,value:de}=await p.read();if(Z)break;if(!de||de.byteLength===0)continue;W+=de.byteLength;let ce=de;if(A<m){let Q=m-A;if(ce.byteLength<=Q){v.push(ce),A+=ce.byteLength;continue}v.push(ce.subarray(0,Q)),A+=Q,ce=ce.subarray(Q)}E.push(ce),F+=ce.byteLength;while(F>m&&E.length>0){let Q=E[0],me=F-m;if(Q.byteLength<=me)E.shift(),F-=Q.byteLength;else E[0]=Q.subarray(me),F-=me}}}finally{p.releaseLock()}let Y=new TextDecoder,q=Y.decode(Ue(v));if(W<=A+F)return q;let B=Y.decode(Ue(E)),ue=W-A-F;return`${q}${bn(ue)}${B}`}function Ue(o){let i=o.reduce((v,A)=>v+A.byteLength,0),m=new Uint8Array(i),p=0;for(let v of o)m.set(v,p),p+=v.byteLength;return m}async function G(o,i,m){if(typeof o==="function"){await o(i);return}let p=Ae(o),v=V(m.timeoutMs,m.signal),A=Bun.spawn(p,{cwd:m.cwd,env:m.env,stdout:"ignore",stderr:"pipe",stdin:"ignore",...v.spawn}),E=hn(A.stderr).catch(()=>""),F=await A.exited;if(v.timedOut()){let W=(await E).trim();throw Error(`prepare command "${p.join(" ")}" timed out after ${m.timeoutMs}ms before ${i.phase} trial ${i.index}.${W?`
|
|
9
|
-
${W}`:""}`)}if(m.signal?.aborted)return;if(F!==0){let W=(await E).trim();throw Error(`prepare command "${p.join(" ")}" exited with code ${F} before ${i.phase} trial ${i.index}.${W?`
|
|
10
|
-
${W}`:""}`)}}function Ae(o){if(o===void 0||typeof o==="function")return;return Array.isArray(o)?o:b(o)}function De(o){if(o===void 0)return;return{pattern:typeof o.pattern==="string"?o.pattern:o.pattern.source,...o.group!==void 0&&{group:o.group},...o.unit!==void 0&&{unit:o.unit}}}function b(o){return o.trim().split(/\s+/).filter(Boolean)}import{renameSync as yn}from"fs";import{isAbsolute as wn,relative as Tn}from"path";var Le={name:"ostia",version:"0.2.7",description:"Fast profiling and benchmarking for Bun.",type:"module",engines:{bun:">=1.4.0"},exports:{".":"./src/index.ts"},bin:{ostia:"src/cli/main.ts"},scripts:{build:"bun scripts/build.ts",test:"bun test",typecheck:"tsc6","typecheck:package":"tsc6 -p tests/types",lint:"biome check .","lint:fix":"biome check --write . --unsafe","lint:changed":"biome check --changed --no-errors-on-unmatched .","lint:fix:changed":"biome check --write --unsafe --changed --no-errors-on-unmatched .",knip:"knip-bun",bench:"bun src/cli/main.ts bench bench/*.ts","bench:baseline":"bun src/cli/main.ts bench bench/*.ts --budget 3000 --min-samples 30 --export-json .ostia/baselines/bench-main.json",baseline:"bun src/cli/main.ts baseline save",dogfood:"bun test && bun src/cli/main.ts ci",examples:"bun scripts/run-examples.ts"},devDependencies:{"@biomejs/biome":"2.5.14","@types/bun":"^1.4.2",knip:"^6.38.0",typescript:"npm:@typescript/typescript6@^6.0.2"},repository:{type:"git",url:"git+https://github.com/metonym/ostia.git"}};var R=Le.version;function T(o,i){return JSON.stringify(Pe(o),null,i)}function Pe(o){if(Array.isArray(o)){let i=!1;for(let m=0;m<o.length;m++){let p=o[m];if(p!==null&&typeof p==="object"){i=!0;break}}return i?o.map(Pe):o}if(o!==null&&typeof o==="object"){let i=o,m={};for(let p of Object.keys(i).sort())m[p]=Pe(i[p]);return m}return o}function e(o,...i){let m=Bun.CryptoHasher.hash("sha256",T(i),"hex");return`${o}_${m.slice(0,16)}`}var Re,_e=!1;function Oe(o){let i=Bun.spawnSync(["git",...o],{timeout:200,stdout:"pipe",stderr:"ignore"});return i.success?i.stdout.toString().trim():void 0}function We(){if(_e)return Re;_e=!0;try{let o=Oe(["rev-parse","--short","HEAD"]);if(o===void 0)Re=void 0;else{let i=Oe(["rev-parse","--abbrev-ref","HEAD"]),m=Oe(["status","--porcelain"]);Re={sha:o,branch:i??"HEAD",dirty:(m?.length??0)>0}}}catch{Re=void 0}return Re}function r(o,i,m){let p=We();return{schemaVersion:2,toolVersion:R,bunVersion:Bun.version,platform:{os:process.platform,arch:process.arch},createdAt:new Date().toISOString(),workloads:o,measurements:i,...m!==void 0&&{environment:m},...p!==void 0&&{git:p}}}function I(o,i,m={}){if(m.timeSource)H(m.timeSource);let p=Ae(m.prepare),v=De(m.timeSource),A=typeof m.prepare==="function"?m.prepare.toString():p;return{id:e("wl","subprocess",o,...A!==void 0||v!==void 0?[A??null,v??null]:[]),kind:"subprocess",command:o,label:i,...p!==void 0&&{prepare:p},...v!==void 0&&{timeSource:v}}}function se(o,i){return{id:e("wl","inprocess",o.name,o.toString()),kind:"inprocess",label:i}}function Ge(o,i,m={}){let p=wn(o)?Tn(process.cwd(),o):o;return{id:m.params!==void 0?e("wl","inprocess-entry",p,i,m.params):e("wl","inprocess-entry",p,i),kind:"inprocess",entry:{file:o,task:i,...m.group!==void 0&&{group:m.group}},...m.label!==void 0&&{label:m.label},...m.baseline!==void 0&&{baseline:m.baseline},...m.description!==void 0&&{description:m.description},...m.groupDescription!==void 0&&{groupDescription:m.groupDescription},...m.isolated!==void 0&&{isolated:m.isolated},...m.params!==void 0&&{params:m.params},...m.skipped!==void 0&&{skipped:m.skipped}}}function w(o){return{id:e("run",o.workload.id,"timing",o.configFingerprint,Bun.version,R),workloadId:o.workload.id,phase:"timing",instrumented:!1,configFingerprint:o.configFingerprint,trials:o.trials,timing:o.timing,warnings:o.warnings,artifacts:[],memory:xn(o.trials),...o.interleaved!==void 0&&{interleaved:o.interleaved}}}function xn(o){let i=o.map((m)=>m.maxRssBytes).filter((m)=>m!==void 0);if(i.length===0)return;return{origin:"resourceUsage",maxRssBytes:Math.max(...i)}}function y(o){return{id:e("run",o.workload.id,o.phase,o.configFingerprint,Bun.version,R),workloadId:o.workload.id,phase:o.phase,instrumented:!0,configFingerprint:o.configFingerprint,trials:[{i:0,wallNs:o.diagnosticWallNs,exitCode:o.exitCode}],diagnosticWallNs:o.diagnosticWallNs,cpu:o.cpu,heap:o.heap,memory:o.memory,jit:o.jit,warnings:o.warnings,artifacts:o.artifacts}}async function oe(o,i,m){let v=await Bun.file(m).arrayBuffer(),A=new Bun.CryptoHasher("sha256");return A.update(v),{id:e("art",o,i,m),kind:i,path:m,sha256:A.digest("hex"),bytes:v.byteLength}}function c(o){return e("cfg",o)}function k(o){return`${T(o,2)}
|
|
11
|
-
`}async function J(o,i){let m=`${i}.tmp-${process.pid}`;await Bun.write(m,o),yn(m,i)}async function u(o,i){await J(k(o),i)}class x extends Error{code;path;schemaVersion;constructor(o,i,m={}){super(i);this.name="OstiaDocumentError",this.code=o,this.path=m.path,this.schemaVersion=m.schemaVersion}}async function s(o){let i=await Bun.file(o).text(),m;try{m=JSON.parse(i)}catch(v){let A=v instanceof Error?v.message:String(v);throw new x("invalid-json",`${o}: invalid JSON (${A})`,{path:o})}let p=m!==null&&typeof m==="object"?m.schemaVersion:void 0;if(typeof p!=="number")throw new x("not-a-document",`${o}: not a ProfileDocument (missing schemaVersion)`,{path:o});if(p!==2)throw new x("unsupported-schema",`${o}: unsupported ProfileDocument schemaVersion ${p} (this ostia reads 2)`,{path:o,schemaVersion:p});return Sn(m)}function Sn(o){for(let i of o.measurements){let m=i.timing;if(!m||m.mad!==void 0||m.samples.length===0)continue;i.timing={...f(m.samples),...m.batch!==void 0&&{batch:m.batch}}}return o}import Ee from"os";var Mn=200,je=64,Rn=(()=>{let o=new Uint8Array(4096);for(let i=0;i<o.length;i++)o[i]=i*2654435761&255;return o})();function vn(o,i){let m=i;for(let p=0;p<o.length;p++)m^=o[p],m=Math.imul(m,16777619);return m>>>0}function Nn(o){let i=f(o);return{floorPct:i.median===0?0:i.mad/i.median*100,referenceMedianNs:i.median,samples:o.length}}function He(o=Mn){let i=o*1e6,m=[],p=0,v=Bun.nanoseconds(),A=0;while(A<i){let E=Bun.nanoseconds();for(let W=0;W<je;W++)p^=vn(Rn,W);let F=Bun.nanoseconds();m.push((F-E)/je),A=Bun.nanoseconds()-v}return Nn(m)}var In=0.75;function l(){let[o=0,i=0]=Ee.loadavg();return{cpuModel:Ee.cpus()[0]?.model??"unknown",cores:Ee.availableParallelism(),loadAvg1:o,loadAvg5:i,noise:He()}}function d(o){if(o.loadAvg1<=o.cores*In)return;return{code:"noisy-machine",message:`Load average ${o.loadAvg1.toFixed(2)} exceeds 75% of ${o.cores} available core(s); timing noise may be elevated.`,data:{loadAvg1:o.loadAvg1,cores:o.cores}}}import{profile as Pn}from"bun:jsc";var An=new Map([["LLInt","llint"],["Baseline","baseline"],["DFG","dfg"],["FTL","ftl"]]),Je=4294967295;function Ve(o,i){let m=i??o.interval*1e6,p=new Map,v=[];function A(P,K,X,be){let ne=p.get(P);if(ne===void 0)ne=new Map,p.set(P,ne);let he=K??"",xe=ne.get(he);if(xe===void 0)xe=v.length,ne.set(he,xe),v.push({key:e("fr",P,he),name:P,url:K,line:X,col:be});return xe}function E(P){let K=P.line===Je,X=K?void 0:P.line-1,be=K||P.column===Je?void 0:P.column-1;return A(P.name,P.sourceURL,X,be)}let F=A("(root)",void 0,void 0,void 0),W=1,Y={id:0,frameIx:F,children:new Map,selfUs:0,samples:0,totalUs:0},q=new Map([[0,Y]]),B={llint:0,baseline:0,dfg:0,ftl:0},ue=new Map,Z=[],de=[];for(let P of o.traces){let K=P.frames,X=Y;for(let he=K.length-1;he>=0;he--){let xe=E(K[he]),Se=X.children.get(xe);if(!Se)Se={id:W++,frameIx:xe,children:new Map,selfUs:0,samples:0,totalUs:0},X.children.set(xe,Se),q.set(Se.id,Se);X=Se}X.selfUs+=m,X.samples+=1,Z.push(X.id),de.push(m);let be=K[0],ne=be&&An.get(be.category);if(ne){B[ne]++;let he=ue.get(ne)??new Map;he.set(X.frameIx,(he.get(X.frameIx)??0)+1),ue.set(ne,he)}}function ce(P){let K=P.selfUs;for(let X of P.children.values())K+=ce(X);return P.totalUs=K,K}ce(Y);let Q=new Map;function me(P){let K=Q.get(P.frameIx);if(K)K.selfUs+=P.selfUs,K.totalUs+=P.totalUs,K.samples+=P.samples;else Q.set(P.frameIx,{frameIx:P.frameIx,selfUs:P.selfUs,totalUs:P.totalUs,samples:P.samples});for(let X of P.children.values())me(X)}me(Y);let le=[...q.values()].map((P)=>({id:P.id,frameIx:P.frameIx,children:[...P.children.values()].map((K)=>K.id)})),we={origin:"jsc-profile",samplingIntervalUs:m,frames:v,nodes:le,totals:[...Q.values()].sort((P,K)=>K.selfUs-P.selfUs),samples:{nodeIds:Z,timeDeltasUs:de}},Te=[...ue.entries()].flatMap(([P,K])=>[...K.entries()].sort((X,be)=>be[1]-X[1]).slice(0,3).map(([X,be])=>({tier:P,frameKey:v[X].key,samples:be})));return{cpu:we,jit:{origin:"jsc-profile",tiers:B,topFramesByTier:Te}}}var On=1000;async function z(o,i={}){let m=i.intervalUs??On,p,v=Bun.nanoseconds(),A=await Pn(async()=>(p=await o(),p),m),E=Bun.nanoseconds()-v,{cpu:F,jit:W}=Ve(A.stackTraces,m);return{result:p,cpu:F,jit:W,diagnosticWallNs:E}}var En=500,Bn=20,Ke=3,Fn=10,$n=2,Un=0.1,Cn=1000,qe=1e4,Dn=2*qe,Ln=1e6,_n=5,Ye=256;function Ze(o){let i=Math.log10(Math.max(1,o)/1e6),m=Math.round(Ke+$n*i);return Math.min(Fn,Math.max(Ke,m))}function Wn(o,i){let m=Math.floor(i/o);return Math.min(Bn,Math.max(m,Ze(o)))}var Gn;function pe(o){Gn=o}function ve(o){return o!==null&&typeof o==="object"&&typeof o.then==="function"}var jn=(async()=>{}).constructor,Hn=0;function Jn(o){let i=`/* ostia task loop ${Hn++} */
|
|
12
|
-
const t0 = Bun.nanoseconds()
|
|
13
|
-
for (let b = 0; b < n; b++) sink[b & ${Ye-1}] = ${o?"await ":""}fn()
|
|
14
|
-
return Bun.nanoseconds() - t0`;return(o?jn:Function)("fn","sink","n",i)}function ze(o,i){return Math.max(1,Math.ceil(Cn/o),Math.ceil(i/(o*qe)))}function Vn(o){let i=[...o].sort((m,p)=>m-p);return i[i.length>>1]}async function Xe(o,i={}){let m=(i.budgetMs??En)*1e6,p=m*(i.warmup??Un),v=Bun.nanoseconds(),A=o(),E=ve(A);if(E)await A;let F=Math.max(1,Bun.nanoseconds()-v),W=Jn(E),Y=Array(Ye),q=(ne)=>W(o,Y,ne),B=Bun.nanoseconds(),ue=1;while(Bun.nanoseconds()-B<p){let ne=await q(ue);if(F=Math.max(1,ne/ue),ne<Ln)ue*=2}let Z=ze(F,m);if(Z>1){let ne=[];for(let he=0;he<_n;he++)ne.push(await q(Z)/Z);F=Math.max(1,Vn(ne)),Z=ze(F,m)}let de=F*Z,ce=i.samples??i.minSamples??Wn(de,m),Q=i.samples!==void 0?0:m,me=i.samples??Math.max(Dn,ce),le=[],we=Bun.nanoseconds(),Te=0,ye=0;while(ye<ce||Te<Q&&ye<me){let ne=await q(Z);if(le.push({i:ye,wallNs:ne/Z}),ye++,Te=Bun.nanoseconds()-we,i.gc)Bun.gc(!0);if(ye>=me&&ye>=ce)break}let P=le.map((ne)=>ne.wallNs),K=f(P);if(Z>1)K.batch=Z;let X=j(K,[],"inprocess"),be=Ze(de);if(le.length<be)X.push({code:"low-sample-count",message:`Only ${le.length} sample(s) at ~${Kn(de)} per trial; ${be} is the floor for this cost class. Raise minSamples or the time budget for a steadier number.`,data:{samples:le.length,target:be,trialCostNs:de}});return{trials:le,timing:K,warnings:X}}function Kn(o){if(o>=1e9)return`${(o/1e9).toFixed(2)}s`;if(o>=1e6)return`${(o/1e6).toFixed(1)}ms`;if(o>=1000)return`${(o/1000).toFixed(1)}\xB5s`;return`${o.toFixed(0)}ns`}var $e=[],ke,Me;function Be(o,i,m,p){let v=ke;ke={name:o,description:m?.description,isolate:m?.isolate,gc:m?.gc,cpu:m?.cpu,alloc:m?.alloc,before:m?.before,after:m?.after,skip:p.skip,only:p.only};try{i()}finally{ke=v}}var fe=Object.assign((o,i,m)=>Be(o,i,m,{}),{skip:(o,i,m)=>Be(o,i,m,{skip:!0}),only:(o,i,m)=>Be(o,i,m,{only:!0})});function Fe(o,i,m,p){let v=Me!==void 0||m?.params!==void 0?{...Me,...m?.params}:void 0;$e.push({groupName:ke?.name,groupDescription:ke?.description,groupIsolate:ke?.isolate,groupGc:ke?.gc,groupCpu:ke?.cpu,groupAlloc:ke?.alloc,groupBefore:ke?.before,groupAfter:ke?.after,name:o,fn:i,baseline:m?.baseline,params:v,skipped:p.skip||ke?.skip,only:p.only||ke?.only,opts:m})}var ge=Object.assign((o,i,m)=>Fe(o,i,m,{}),{skip:(o,i,m)=>Fe(o,i,m,{skip:!0}),only:(o,i,m)=>Fe(o,i,m,{only:!0})});function O(){return $e}function ie(){$e.length=0,ke=void 0,Me=void 0}function ae(o,i){let m=Me;Me=o;try{return i()}finally{Me=m}}function C(o){return o.groupName?`${o.groupName}/${o.name}`:o.name}function ee(o,i){return o.opts?.isolate??o.groupIsolate??i}function Qe(o,i){return o.opts?.gc??o.groupGc??i}function en(o,i){return o.opts?.cpu??o.groupCpu??i}function nn(o,i){return o.opts?.alloc??o.groupAlloc??i}function zn(o,i){if(!i)return[...o];let m=new RegExp(i);return o.filter((p)=>m.test(C(p)))}function D(o,i,m){let p=o.filter((E)=>E.only),v=p.length>0?p:o;if(p.length>0)process.stderr.write(`bench: ${p.length} task(s) selected by .only
|
|
15
|
-
`);let A=zn(v,i);if(A.length===0)throw Error(`filter ${JSON.stringify(i)} matched zero of ${v.length} registered task(s) in ${m}.`);return A}import{heapStats as qn}from"bun:jsc";var Yn=100;function tn(){try{return qn().heapSize}catch{return process.memoryUsage().heapUsed}}async function rn(o,i=Yn){let m=Bun.nanoseconds();Bun.gc(!0);let p=tn();for(let E=0;E<i;E++){let F=o();if(ve(F))await F}Bun.gc(!0);let v=tn(),A=Bun.nanoseconds()-m;return{memory:{origin:"heapStats",bytesPerOp:Math.max(0,(v-p)/i)},diagnosticWallNs:A}}var Zn=200,Xn=20;async function on(o,i=Zn){let m=i*1e6,p=async()=>{let F=Bun.nanoseconds();while(Bun.nanoseconds()-F<m){let W=o();if(ve(W))await W}},{cpu:v,jit:A,diagnosticWallNs:E}=await z(p);return{cpu:v,jit:A,diagnosticWallNs:E}}function sn(o){let{llint:i,baseline:m,dfg:p,ftl:v}=o.tiers,A=i+m+p+v;if(A===0)return;let E=i/A*100,F=m/A*100,W=p/A*100,Y=v/A*100;if(E+F<=Xn)return;return{code:"jit-cold",message:`${(E+F).toFixed(1)}% of CPU samples were in the llint/baseline tiers: the JIT never warmed this task up.`,data:{llintPct:E,baselinePct:F,dfgPct:W,ftlPct:Y}}}async function N(o,i,m){let v=i.some((q)=>!q.skipped)&&m.noiseCheck!==!1?l():void 0,A=v?d(v):void 0,E=new Map,F=new Map;i.forEach((q,B)=>{if(q.groupName===void 0||q.skipped)return;if(!E.has(q.groupName))E.set(q.groupName,B);F.set(q.groupName,B)});let W=[],Y=[];for(let q=0;q<i.length;q++){let B=i[q],ue=C(B),Z=Ge(o,ue,{label:ue,baseline:B.baseline,group:B.groupName,description:B.opts?.description,groupDescription:B.groupDescription,isolated:m.markIsolated,params:B.params,skipped:B.skipped});if(W.push(Z),B.skipped)continue;let de=B.groupName!==void 0&&E.get(B.groupName)===q,ce=B.groupName!==void 0&&F.get(B.groupName)===q;if(de&&B.groupBefore)await B.groupBefore();if(B.opts?.before)await B.opts.before();let Q={budgetMs:B.opts?.budgetMs??m.budgetMs,samples:B.opts?.samples??m.samples,minSamples:B.opts?.minSamples??m.minSamples,warmup:m.warmup,gc:Qe(B,m.gc??!1)},me=await Xe(B.fn,Q);if(Y.push(w({workload:Z,configFingerprint:c({budgetMs:Q.budgetMs??null,samples:Q.samples??null,minSamples:Q.minSamples??null,gc:Q.gc??!1}),trials:me.trials,timing:me.timing,warnings:A&&Y.length===0?[...me.warnings,A]:me.warnings})),en(B,m.cpu??!1)){let le=await on(B.fn),we=sn(le.jit);Y.push(y({workload:Z,phase:"cpu",configFingerprint:c({cpu:!0}),diagnosticWallNs:le.diagnosticWallNs,cpu:le.cpu,jit:le.jit,warnings:we?[we]:[],artifacts:[]}))}if(nn(B,m.alloc??!1)){let le=await rn(B.fn);Y.push(y({workload:Z,phase:"memstats",configFingerprint:c({alloc:!0}),diagnosticWallNs:le.diagnosticWallNs,memory:le.memory,warnings:[],artifacts:[]}))}if(B.opts?.after)await B.opts.after();if(ce&&B.groupAfter)await B.groupAfter()}return r(W,Y,v)}
|
|
16
|
-
export{T,e,M,S,n,U,g,t,L,te,h,_,f,a,j,H,V,re,G,b,R,r,I,se,w,y,oe,c,k,J,u,x,s,l,d,z,pe,fe,ge,O,ie,ae,C,ee,D,N};
|