D4rtProfiler class

Compile-time-gated profiler for D4rt's initialization path.

This profiler measures the one-time setup work that happens when a D4rt runner is constructed and prepared for a run — bridge finalization, warm-parent environment assembly, stdlib registration, module-loader construction, and the declaration/registration passes that precede the actual main() call. It is not a profiler for the interpreter's hot path; instrumentation deliberately stops at the point where script interpretation begins.

Zero runtime cost when disabled

enabled is a static const bool. Every measurement site is written as an if (D4rtProfiler.enabled) { ... } guard (or a D4rtProfiler.enabled ? ... : null ternary). When enabled is false the Dart compiler (VM TFA / AOT / dart2js) constant-folds the condition and eliminates the guarded code entirely — no Stopwatch allocation, no map lookup, and no call overhead in a normal run.

CRITICAL — never publish with enabled == true

Flip enabled to true only for a local profiling session, then revert it before committing or publishing the package. A true value would leave the instrumentation live in shipped builds. A guard test (test/profiler_disabled_test.dart) asserts it stays false.

Twin of tom_d4rt/lib/src/profiler.dart — keep both in sync.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

hasData bool
Whether any spans have been recorded.
no setter

Static Methods

record(String name, int micros) → void
Records an elapsed micros span under name.
report({String title = 'D4rt init profile'}) String
Human-readable multi-line report, longest span first.
reset() → void
Clears all recorded spans (e.g. between profiling runs).
snapshot() Map<String, dynamic>
JSON-serializable snapshot: {name: {us, ms, n}} in record order.

Constants

enabled → const bool
Master compile-time switch. MUST remain false in published code.