timing
1.0.2, released 2 years ago by tools.dart.dev
Measures duration of synchronous and asynchronous actions with optional JSON serialization.
What it does
Provides trackers to time code blocks and collect detailed timing slices. Supports both sync and async actions and can serialize results via json_serializable.
AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need lightweight performance timing in Dart/Flutter code
- You want JSON‑serializable timing data for logging or analytics
Skip it when
- You require visual profiling charts or deep flame‑graph analysis
- You need a full‑featured benchmarking suite
Strengths
- Simple, easy‑to‑use API
- Handles both sync and async actions
- Integrates with json_serializable for easy data export
Weaknesses
- Limited to basic timing, no advanced profiling features
- Requires build_runner step for code generation
- No UI or visualization tools
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 1
Run `dart pub run build_runner build` to generate serialization code
var tracker = AsyncTimeTracker();
await tracker.track(() async {
// some async code here
});
print('${tracker.duration} ${tracker.innerDuration} ${tracker.slices}');Alternatives
Packages that do the same job and could replace timing.
- snowplow_tracker
Flutter package for sending Snowplow analytics events on Android, iOS, and Web.
78Compare - structured_async
Structured asynchronous programming and cancellable futures for Dart.
39Compare
Works with
Packages commonly used together with timing: ones it builds on, ones built on it, and its own family.