Construct an EventRange.
Get the number of remaining bytes in the underlying profile data.
Are there no more events?
Get the current event.
Move to the next event.
Get a copy of the range in its current state.
// Filter zones based on the info string. Useful to determine durations of only // certain zones. import tharsis.prof; auto storage = new ubyte[Profiler.maxEventBytes + 2048]; auto profiler = new Profiler(storage); // Simulate 8 'frames' foreach(frame; 0 .. 8) { Zone topLevel = Zone(profiler, "frame"); // Simulate frame overhead. Replace this with your frame code. { Zone nested1 = Zone(profiler, "frameStart"); foreach(i; 0 .. 1000) { continue; } } { Zone nested2 = Zone(profiler, "frameCore"); foreach(i; 0 .. 10000) { continue; } } } import std.stdio; // Create an EventRange from profile data with UFCS syntax. auto events = profiler.profileData.eventRange; // Foreach over range calls popFront()/front()/empty() internally foreach(event; events) { writeln(event); } // Get a range of only the events with start time between 1000 and 5000 (hectonanoseconds) // // This doesn't filter anything or allocate; filtering only happens once the // range is iterated over (but if we did want to do the filtering right now, e.g. to // get an array of filtered results, we'd suffix this with ".array") auto filtered = events.filter!(e => e.time > 1500 && e.time < 2000); // Here, we print the IDs of events between 10000 and 50000 hectonanoseconds foreach(id; filtered.map!(e => e.id)) { writeln(id); } // And here we count the number of events between 1000 and 5000 writeln(filtered.count);
Light-weight type-safe range that iterates over events in profile data.
EventRange is a 'low-level' range to base other ranges or structures (such as ZoneRange) on top of.
Doesn't allocate any heap memory.