in lib/src/timing.dart [243:286]
T _trackSyncSlice<T>(ZoneDelegate parent, Zone zone, T Function() action) {
// Ignore dangling runs after tracker completes
if (isFinished) {
return action();
}
final isNestedRun = slices.isNotEmpty &&
slices.last is SyncTimeTracker &&
(slices.last as SyncTimeTracker).isTracking;
final isExcludedNestedTrack = !trackNested && zone[_zoneKey] != this;
// Exclude nested sync tracks
if (isNestedRun && isExcludedNestedTrack) {
final timer = slices.last as SyncTimeTracker;
// Split already tracked time into new slice.
// Replace tracker in slices.last with splitted slice, to indicate for
// recursive calls that we not tracking.
slices.last = parent.run(zone, timer._split);
try {
return action();
} finally {
// Split tracker again and discard slice that was spend in nested tracker
parent.run(zone, timer._split);
// Add tracker back to list of slices and continue tracking
slices.add(timer);
}
}
// Exclude nested async tracks
if (isExcludedNestedTrack) {
return action();
}
// Split time slices in nested sync runs
if (isNestedRun) {
return action();
}
final timer = SyncTimeTracker();
slices.add(timer);
// Pass to parent zone, in case of overwritten clock
return parent.runUnary(zone, timer.track, action);
}