Add timeit to measure test timings
This commit is contained in:
parent
76d9be756a
commit
492eba8f22
4 changed files with 36 additions and 14 deletions
|
|
@ -2,16 +2,11 @@ import strutils
|
|||
|
||||
proc testCall(cmd, output: string, exitCode: int, delete = true) =
|
||||
var
|
||||
ccmd =
|
||||
when defined(windows):
|
||||
"cmd /c " & cmd
|
||||
else:
|
||||
cmd
|
||||
ccmd = "../tests/timeit " & cmd
|
||||
|
||||
if not delete:
|
||||
ccmd = ccmd.replace(" -f ", " ")
|
||||
|
||||
echo ccmd
|
||||
var
|
||||
(outp, exitC) = gorgeEx(ccmd)
|
||||
echo outp
|
||||
|
|
|
|||
22
tests/timeit.nim
Normal file
22
tests/timeit.nim
Normal 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)
|
||||
|
|
@ -9,7 +9,7 @@ withDir("wrappers"):
|
|||
for wrapper in wrappers:
|
||||
let
|
||||
name = wrapper.extractFilename()
|
||||
exec "git clone https://github.com/" & wrapper
|
||||
exec "../../tests/timeit git clone https://github.com/" & wrapper
|
||||
withDir(name):
|
||||
exec "nimble install -d"
|
||||
exec "nimble test"
|
||||
exec "../../../tests/timeit nimble install -d"
|
||||
exec "../../../tests/timeit nimble test"
|
||||
Loading…
Add table
Add a link
Reference in a new issue