1 module chimpfella.measurement.phobostimer; 2 @safe: 3 @nogc: 4 struct PhobosTimer { 5 enum MeasurementName = "PhobosTimer"; 6 size_t eventCount() const 7 { 8 return 1; 9 } 10 string[][] getHeader() const { 11 static _data = [["PhobosTimer"]]; 12 return _data; 13 } 14 import std.datetime.stopwatch; 15 public static struct StateT { 16 @disable this(this); 17 StopWatch timer; 18 pragma(inline, true) 19 void start() 20 { 21 timer.start(); 22 } 23 pragma(inline, true) 24 void stop() 25 { 26 timer.stop(); 27 } 28 void read(T)(T[] output) const 29 { 30 output[0] = timer.peek.total!"nsecs"; 31 } 32 } 33 this(string x) 34 { 35 36 } 37 StateT getState() 38 { 39 StateT tmp; 40 tmp.timer = StopWatch(AutoStart.no); 41 return tmp; 42 } 43 }