Documentation
¶
Overview ¶
Package drivebench owns the run.json artifact schema shared by the Drive startup benches. The unbundled bench (e2e/wasm) and the bundled production bench (e2e/releasewasm) cannot import each other's test symbols, so the cell-comparable schema and its artifact paths live here as the single contract both harnesses write.
Index ¶
- Constants
- func CellDir(runStamp string, cell string) (string, error)
- func CountDriveSeedResourceCalls(phases []Phase) int
- func WriteArtifact(path string, data []byte) error
- func WriteRun(dir string, run Run) (string, error)
- type Browser
- type BrowserProfile
- type Bundle
- type Milestones
- type OperationField
- type OperationShape
- type OperationSummary
- type Phase
- type ProfileBucket
- type ResourceConn
- type Run
- type StartupMark
- type Task
- type Trace
Constants ¶
const StartupMarksScript = `` /* 433-byte string literal not displayed */
StartupMarksScript reads the page startup-mark timeline into a JSON-able array ordered by performance.now start time. Each entry carries the mark label, its start time in milliseconds from navigation start, and the boundary detail markStartupBoundary stored on the performance mark (sequence, phase, mode, source). Both Drive benches evaluate it on the page after content-ready so the captured marks span the full boot-to-content window.
Variables ¶
This section is empty.
Functions ¶
func CellDir ¶
CellDir returns the artifact directory for one bench cell under the repo-root .bldr tree, grouped by the run stamp shared across the run's cells.
func CountDriveSeedResourceCalls ¶
CountDriveSeedResourceCalls counts the timed Resource SDK calls that the Drive quickstart seed issues after populate-space begins and before content is ready. Wrapper phases such as populate-space and init-drive-unixfs are omitted because their leaf transaction phases carry the actual RPC calls.
func WriteArtifact ¶
WriteArtifact writes data to path, creating the parent directory tree. Bench cells use it for the raw runtime.trace and tracetool.txt artifacts alongside run.json.
Types ¶
type Browser ¶
type Browser struct {
ContentReadyMs int `json:"contentReadyMs"`
QuickstartState string `json:"quickstartState"`
QuickstartProgressReadyMs *int `json:"quickstartProgressReadyMs,omitempty"`
QuickstartContentReadyMs *int `json:"quickstartContentReadyMs,omitempty"`
QuickstartFinishedMs *int `json:"quickstartFinishedMs,omitempty"`
QuickstartPhases []Phase `json:"quickstartPhases,omitempty"`
DriveSeedResourceCalls int `json:"driveSeedResourceCalls,omitempty"`
DriveSeedStartedMs *int `json:"driveSeedStartedMs,omitempty"`
DriveSeedFinishedMs *int `json:"driveSeedFinishedMs,omitempty"`
DriveSeedElapsedMs *int `json:"driveSeedElapsedMs,omitempty"`
StartupMarks []StartupMark `json:"startupMarks,omitempty"`
}
Browser carries the browser-side quickstart timing reported by the Drive viewer, independent of the Go-side wall clock.
type BrowserProfile ¶
type BrowserProfile struct {
Captured bool `json:"captured"`
ProfilePath string `json:"profilePath,omitempty"`
SummaryPath string `json:"summaryPath,omitempty"`
CaptureWindow string `json:"captureWindow,omitempty"`
StartedAt string `json:"startedAt,omitempty"`
StoppedAt string `json:"stoppedAt,omitempty"`
Bytes int `json:"bytes,omitempty"`
SkippedReason string `json:"skippedReason,omitempty"`
Buckets []ProfileBucket `json:"buckets,omitempty"`
}
BrowserProfile records the optional same-window browser JS CPU/profile artifact. It is present only when the harness attempted the profile gate.
type Bundle ¶
type Bundle struct {
TotalBytes int64 `json:"totalBytes"`
WasmBytes int64 `json:"wasmBytes"`
FileCount int `json:"fileCount"`
}
Bundle is the served code payload measured from the built bundle on disk: the total JavaScript-plus-WASM module bytes, the WASM subtotal, and the module file count. It is a bundled-build metric, so only the bundled bench populates it. The page resource timeline cannot supply it because the runtime loads its modules inside a worker, off the main-thread timeline. The GoScript build is all-JavaScript, so WasmBytes is zero for GoScript and non-zero only for the TinyGo/Go-WASM builds.
func MeasureBundleDir ¶
MeasureBundleDir walks root and sums the served code-payload modules (.mjs/.js plus .wasm), reporting the total bytes, the WASM subtotal, and the module file count. It measures the built bundle on disk, the size the runtime loads, giving the Phase bundle-size baseline a stable number the page resource timeline cannot provide.
type Milestones ¶
type Milestones struct {
LiveAppMs int64 `json:"liveAppMs"`
RouteAcceptedMs int64 `json:"routeAcceptedMs"`
UnixfsVisibleMs int64 `json:"unixfsVisibleMs"`
ContentReadyMs int64 `json:"contentReadyMs"`
}
Milestones records wall-clock milliseconds from navigation start to each boot milestone. ContentReadyMs is the moment getting-started.md is present in the file browser, which is also when the first file row renders.
type OperationField ¶
type OperationField struct {
Name string `json:"name"`
Samples int `json:"samples"`
Sum int64 `json:"sum"`
Max int64 `json:"max"`
Last int64 `json:"last"`
}
OperationField summarizes one numeric field recovered from trace logs.
type OperationShape ¶
type OperationShape struct {
Operations []OperationSummary `json:"operations,omitempty"`
}
OperationShape is the compact per-run storage/frontier summary derived from runtime trace tasks and numeric trace-log payloads. Raw runtime.trace remains the replay source; this projection is the comparison surface for plan ranking.
type OperationSummary ¶
type OperationSummary struct {
Name string `json:"name"`
Count int `json:"count,omitempty"`
TotalUs int64 `json:"totalUs,omitempty"`
MaxUs int64 `json:"maxUs,omitempty"`
LogCount int `json:"logCount,omitempty"`
Fields []OperationField `json:"fields,omitempty"`
}
OperationSummary groups task timing and recovered numeric log payloads under a stable operation name, such as block-write or opfs-publish.
type Phase ¶
type Phase struct {
Name string `json:"name"`
StartedMs int `json:"startedMs"`
FinishedMs *int `json:"finishedMs,omitempty"`
ElapsedMs *int `json:"elapsedMs,omitempty"`
Error string `json:"error,omitempty"`
}
Phase is one browser-observed quickstart phase. The timestamps use the page performance.now timebase, matching the quickstart timing object published by the app while the bench is running.
type ProfileBucket ¶
type ProfileBucket struct {
Name string `json:"name"`
Count int `json:"count,omitempty"`
SelfUs int64 `json:"selfUs,omitempty"`
TotalUs int64 `json:"totalUs,omitempty"`
}
ProfileBucket is one source/function bucket from the browser JS CPU profile.
type ResourceConn ¶
type ResourceConn struct {
DurationMs int64 `json:"durationMs"`
Attempts int `json:"attempts"`
StartupReloads int `json:"startupReloads"`
}
ResourceConn summarizes the Resource SDK connection timing for the session. The bundled production bench leaves it zero because it has no SDK client.
type Run ¶
type Run struct {
Timestamp string `json:"timestamp"`
Compiler string `json:"compiler"`
BuildMode string `json:"buildMode"`
RuntimeState string `json:"runtimeState"`
Cell string `json:"cell"`
Milestones Milestones `json:"milestones"`
Browser Browser `json:"browser"`
ServedBundle *Bundle `json:"servedBundle,omitempty"`
ResourceConnection ResourceConn `json:"resourceConnection"`
Trace *Trace `json:"trace,omitempty"`
OperationShape *OperationShape `json:"operationShape,omitempty"`
BrowserProfile *BrowserProfile `json:"browserProfile,omitempty"`
}
Run is one bench cell artifact: the resolved build identity, wall-clock milestones from navigation start to Drive content-ready, the browser-observed quickstart timing, the served bundle size, the Resource SDK connection timing, and optional trace/profile summaries. It is written as run.json per cell so cells compare across runtime states and build modes. The bundled production bench has no Go trace service and no Resource SDK client, so it omits Trace and leaves ResourceConnection zero.
type StartupMark ¶
type StartupMark struct {
Label string `json:"label"`
Sequence int `json:"sequence,omitempty"`
StartMs int `json:"startMs"`
Phase string `json:"phase,omitempty"`
Mode string `json:"mode,omitempty"`
Source string `json:"source,omitempty"`
Detail map[string]any `json:"detail,omitempty"`
}
StartupMark is one startup-boundary mark observed on the page performance timeline, emitted by markStartupBoundary. StartMs is the mark's performance.now time in milliseconds from navigation start, so marks share the timebase of the bundled milestones and quickstart phases. The pre-quickstart startup gap is attributed by reading the interval between adjacent marks: the gap belongs to whichever mark transition spans it.
func ParseStartupMarks ¶
func ParseStartupMarks(raw any) []StartupMark
ParseStartupMarks parses the page startup-mark timeline captured with StartupMarksScript. Marks arrive ordered by performance.now start time; the parser preserves that order so the pre-quickstart gap reads as the interval between adjacent marks. Entries without a label are skipped.
type Task ¶
type Task struct {
Type string `json:"type"`
Count int `json:"count"`
TotalUs int64 `json:"totalUs"`
MaxUs int64 `json:"maxUs"`
}
Task is an aggregate runtime-trace task summary keyed by Go user task type.
type Trace ¶
type Trace struct {
Bytes int `json:"bytes"`
RuntimeTracePath string `json:"runtimeTracePath"`
TracetoolPath string `json:"tracetoolPath"`
UserTasks int `json:"userTasks"`
UserRegions int `json:"userRegions"`
UserLogs int `json:"userLogs"`
Tasks []Task `json:"tasks,omitempty"`
}
Trace summarizes the captured runtime trace and the paths of the raw trace plus its tracetool extraction.