5.3 KiB
5.3 KiB
@suaveplan/profiler - Universal runtime performance profiler — Profiler/Sampler/MemoryProfiler/BottleneckDetector/ProfileComparator/FlameGraphGenerator/ProfileReporter/OtelExporter with injectable Clock+TimersLike+HeapCapture, PROFILER_CODES error registry, and OTel self-telemetry.
Universal runtime performance profiler.
Documentation tree
- bottleneck —
BottleneckDetectoranalyses arrays ofProfileEntryrecords to surface performance bottlenecks. It groups entries by…- bottleneck —
BottleneckDetectoranalyses arrays ofProfileEntryrecords to surface performance bottlenecks. It groups entries by…
- bottleneck —
- comparison —
ProfileComparatordiffs two sets of profiling data — either rawProfileEntry[]arrays or pre-aggregated `ProfileRep…- comparison —
ProfileComparatordiffs two sets of profiling data — either rawProfileEntry[]arrays or pre-aggregated `ProfileRep…
- comparison —
- error-codes — Defines the stable error-code registry for
@suaveplan/profilerand the typedProfilerErrorclass consumers throw fr…- error-codes — Defines the stable error-code registry for
@suaveplan/profilerand the typedProfilerErrorclass consumers throw fr…
- error-codes — Defines the stable error-code registry for
- flamegraph —
FlameGraphGeneratorbuilds a flame-graph data structure fromProfileEntryarrays by nesting entries on start/end-ti…- flamegraph —
FlameGraphGeneratorbuilds a flame-graph data structure fromProfileEntryarrays by nesting entries on start/end-ti…
- flamegraph —
- memory —
MemoryProfilercaptures periodic heap snapshots, records labelled allocation totals, tracks a peak-heap watermark, an…- memory —
MemoryProfilercaptures periodic heap snapshots, records labelled allocation totals, tracks a peak-heap watermark, an…
- memory —
- otel —
OtelExporterconvertsProfileEntryrecords to OTLP-compatible spans and optionally exports them to a collector endp…- otel —
OtelExporterconvertsProfileEntryrecords to OTLP-compatible spans and optionally exports them to a collector endp…
- otel —
- profiler —
Profileris the core measurement primitive of@suaveplan/profiler. It records timing entries between paired `start(…- profiler —
Profileris the core measurement primitive of@suaveplan/profiler. It records timing entries between paired `start(…
- profiler —
- reporter —
ProfileReportercomputes summary statistics from profiling entries — count, min, max, mean, median, configurable perc…- reporter —
ProfileReportercomputes summary statistics from profiling entries — count, min, max, mean, median, configurable perc…
- reporter —
- sampler —
Samplercollects periodic snapshots of runtime metrics (memory usage by default, plus caller-supplied custom metrics)…- sampler —
Samplercollects periodic snapshots of runtime metrics (memory usage by default, plus caller-supplied custom metrics)…
- sampler —
- telemetry — Owns the OpenTelemetry meter, counters, and histograms emitted by
@suaveplan/profileritself. Every public completion…- telemetry — Owns the OpenTelemetry meter, counters, and histograms emitted by
@suaveplan/profileritself. Every public completion…
- telemetry — Owns the OpenTelemetry meter, counters, and histograms emitted by
Modules
profiler/—Profiler: start/stop/mark/measure with injectableClock.sampler/—Sampler: periodic metric collection driven byTimersLike.memory/—MemoryProfiler: heap snapshots, allocation tracking, leak detection.bottleneck/—BottleneckDetector: hot-spot + budget-violation analysis.comparison/—ProfileComparator: regressions / improvements / unchanged.flamegraph/—FlameGraphGenerator: containment-tree builder + d3 JSON.reporter/—ProfileReporter: percentile stats + text format.otel/—OtelExporter: OTLP-compatible JSON exporter.error-codes/—PROFILER_CODES+ProfilerError.telemetry/— OTel meter for the profiler itself.
Install
bun add @suaveplan/profiler
Usage
import { Profiler, ProfileReporter, OtelExporter } from "@suaveplan/profiler";
const profiler = new Profiler();
profiler.start("render", "ui");
// ... work ...
profiler.stop("render");
const reporter = new ProfileReporter({ alertThreshold: 16 });
console.log(reporter.formatReport(reporter.generateReport(profiler.getEntries())));
const exporter = new OtelExporter({ serviceName: "my-app" });
await exporter.export(exporter.convertEntries(profiler.getEntries()));
License
MIT