Add timeit to measure test timings

This commit is contained in:
Ganesh Viswanathan 2020-04-28 20:48:21 -05:00
commit 492eba8f22
4 changed files with 36 additions and 14 deletions

22
tests/timeit.nim Normal file
View file

@ -0,0 +1,22 @@
import std/monotimes, os, osproc, sequtils, strformat, strutils, times
when isMainModule:
var params = commandLineParams()
params.apply(quoteShell)
let cmd = params.join(" ")
echo &"================\nRunning: {cmd}\n"
let
start = getMonoTime()
ret = execCmd(cmd)
endt = getMonoTime()
outf = getAppDir() / "timeit.txt"
outd = if fileExists(outf): readFile(outf) else: ""
outp = &"\nRan: {cmd}\nTime taken: {$(endt - start)}\n"
echo outp
writeFile(outf, outd & outp)
quit(ret)