Skip to content

Latest commit

 

History

History
99 lines (77 loc) · 5.52 KB

schema.md

File metadata and controls

99 lines (77 loc) · 5.52 KB

JSON output: typescript-perf/v1

Every command accepts --json and prints one object. The machine-readable schema is schema/typescript-perf-v1.schema.json (JSON Schema 2020-12), also exported as typescript-perf/schema.json. The test suite validates real reports against it on every run.

Versioning. New optional fields can be added within typescript-perf/v1. Renaming, removing or changing the meaning of a field bumps the schema to typescript-perf/v2. Check schema before reading anything else.

Envelope

Field Type
schema "typescript-perf/v1"
tool { name: "typescript-perf", version }
command "analyze" | "why" | "compare" | "budget" | "ts7" analyze is plain typescript-perf
environment { node, platform, arch, cpus, cpuModel, memoryGB, ci } timings only compare on the same machine
measurement Measurement analyze, budget --init
findings Finding[] analyze (absent with --no-findings)
checks Check[] analyze: every check that ran, { id, status: "passed" | "finding" | "not-applicable", detail }
why WhyReport why
comparison Comparison compare
budget BudgetReport budget, and compare when a budget is configured
ts7 Ts7Report ts7

Stat

Every measured number is a Stat: { median, min, max, values }. values holds every run in order, so you can compute anything else. typescript-perf compares medians, and calls a difference real only when it is outside the run-to-run range.

Measurement

Field
compiler { name, version, major, bin, native, source }. source is the package it came from, or "explicit" for --tsc
project, cwd tsconfig (relative to cwd)
mode "project" (tsc -p) or "build" (tsc -b, for project references)
runs, warmup, flags how it was measured. flags are extra compiler flags, e.g. ["--skipLibCheck"] while verifying
total { project, checkTimeMs, totalTimeMs?, memoryMB?, files?, lines?, types?, instantiations? } (Stats, except lines)
projects per referenced project, in build order (build mode only)
stability { counters: "identical" | "varies", counterSpreadPct, checkTimeSpreadPct }
diagnostics the compiler's errors exactly as printed with --pretty false, sorted
warnings why these numbers may not mean what they seem, e.g. the compiler stopped on tsconfig errors before checking

All numbers come from the compiler's own --extendedDiagnostics. memoryMB is the compiler's "Memory used": the V8 heap on TypeScript 5/6 and the Go heap on 7. It is not the process RSS, and it is measured differently by each compiler. TypeScript 5/6 print times in 10 ms steps.

Finding

Field
id skip-lib-check, implicit-types, stray-files, barrel-imports, duplicate-packages, explicit-return-types, checkers
severity high, medium, low
title, why, fix text
evidence measured facts, at least one. A finding never exists without them
where { file, line?, column? }[]
patch { compilerOptions?, exclude?, command? } when the fix is mechanical
verification see below
docs, lab URLs

verification.status:

  • verified: typescript-perf applied the fix (a flag on the command line or a temporary tsconfig, never your files), measured again, every run was faster than every baseline run, and diagnosticsIdentical is true. before and after hold the two check-time Stats and method says how the fix was applied. The schema rejects a verified finding without identical diagnostics.
  • rejected: it was tried and either changed the diagnostics (detail says how many appear and disappear) or gave no gain outside the noise.
  • suggested: it cannot be applied automatically (it needs a decision about your code or your lockfile). The evidence is still measured.

WhyReport

compiler, project, traceDir, checkers (1 on TypeScript 5/6), totalCheckMs (summed over checkers on 7), topFiles, topExpressions, instantiationHotSpots ({ name, file, line, count, perChecker? }: types created per declaration), duplicates, patterns (proven patterns, each with pattern, where, evidence, why, fix, docs), items (everything, in display order), perfetto ({ file, url }).

The trace is deleted after the analysis unless --open is given.

Comparison

baseRef, baseSha, headSha, compiler, runs, base and head (Measurements from interleaved runs), deltas ({ metric, base, head, delta, deltaPct, noise: { base, head }, withinNoise }), attribution (with --why: { name, file, line, base, head, delta } instantiation changes per declaration) and failures (the --fail-on rules that were crossed).

BudgetReport

configPath, passed, results ({ metric, max, tolerancePct, limit, actual, status, message }), measurement. actual is null when the compiler does not report that metric.

Ts7Report

from and to ({ compiler, measurement }), singleThreaded (when the compiler supports --singleThreaded), checkers ({ value, checkTimeMs, totalTimeMs? }[], when it supports --checkers), diagnostics ({ added, removed }, excluding tsconfig errors), config ({ deprecated, removed }, from each compiler's own TS5xxx diagnostics), summary (factual sentences) and warnings (conditions whose check-time spread is above 10%, also repeated in summary).