Is the range empty (no more events)?
Get the current event.
Move to the next event in the range.
import tharsis.prof; auto storage = new ubyte[Profiler.maxEventBytes + 2048]; auto profiler = new Profiler(storage); // Simulate 2 'frames' foreach(frame; 0 .. 2) { Zone topLevel = Zone(profiler, "frame"); // Simulate frame overhead. Replace this with your frame code. { Zone nested1 = Zone(profiler, "with,comma"); foreach(i; 0 .. 1000) { continue; } } { Zone nested2 = Zone(profiler, "with\"quotes\" and\nnewline"); nested2.variableEvent!"float 3.14"(3.14f); nested2.variableEvent!"float 10.1"(10.1f); nested2.variableEvent!"int without comma"(314); foreach(i; 0 .. 10000) { continue; } } } import std.stdio; writeln("Tharsis.prof CSV writing example"); // Create an EventRange from profile data with UFCS syntax. auto events = profiler.profileData.eventRange; import std.array; auto appender = appender!string(); events.writeCSVTo(appender); writeln(appender.data); writeln("Tharsis.prof CSV parsing example"); import std.csv; import std.range; // Parse the CSV back into events. // // Direct file input could work like this (it might be faster to load the entire file // to a buffer, though): // // import std.algorithm // foreach(event; csvEventRange(File("values.csv").byLine.joiner)) foreach(original, parsed; lockstep(events, csvEventRange(appender.data))) { import std.conv: to; assert(original == parsed, original.to!string ~ "\n does not match\n" ~ parsed.to!string); writeln(parsed); }
A range that parses CSV data from a character range (string, file, etc.) and lazily generates Events.
front() and popFront() may throw ConvException or CSVException.