Created
September 23, 2019 21:52
-
-
Save Hackerpilot/1cf9a05e9737d21f0d125b117da109fa to your computer and use it in GitHub Desktop.
Timing code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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