Skip to content

Instantly share code, notes, and snippets.

@Hackerpilot
Created September 23, 2019 21:52
Show Gist options
  • Save Hackerpilot/1cf9a05e9737d21f0d125b117da109fa to your computer and use it in GitHub Desktop.
Save Hackerpilot/1cf9a05e9737d21f0d125b117da109fa to your computer and use it in GitHub Desktop.
Timing code
enum timingSetup = q{
import std.datetime.stopwatch : AutoStart, StopWatch;
import std.stdio : writeln;
import std.conv : to;
auto sw = StopWatch(AutoStart.yes);
size_t lastLine = __LINE__;
};
template timingCheckpoint(size_t l)
{
import std.conv : to;
enum timingCheckpoint = `{
immutable ll = lastLine;
lastLine = ` ~ to!string(l) ~ `;
sw.stop();
writeln("Lines ", ll, " - ", lastLine , ": ", sw.peek());
sw.reset();
sw.start();
}`;
}
mixin(timingSetup);
mixin(timingCheckpoint!__LINE__);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment