diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2020-04-28 20:48:21 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2020-04-28 20:48:21 -0500 |
| commit | 492eba8f22c6fb0070274590490f2977e357de2a (patch) | |
| tree | aa93db0fc3bab2735c44da585c666cbe63709876 /tests | |
| parent | 76d9be756a540272cc7a910eb0730297643276f7 (diff) | |
| download | nimterop-492eba8f22c6fb0070274590490f2977e357de2a.tar.gz nimterop-492eba8f22c6fb0070274590490f2977e357de2a.zip | |
Add timeit to measure test timings
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/getheader.nims | 7 | ||||
| -rw-r--r-- | tests/timeit.nim | 22 | ||||
| -rw-r--r-- | tests/wrappers.nims | 6 |
3 files changed, 26 insertions, 9 deletions
diff --git a/tests/getheader.nims b/tests/getheader.nims index ef501ab..72407f9 100644 --- a/tests/getheader.nims +++ b/tests/getheader.nims @@ -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 diff --git a/tests/timeit.nim b/tests/timeit.nim new file mode 100644 index 0000000..b52eae5 --- /dev/null +++ b/tests/timeit.nim @@ -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)
\ No newline at end of file diff --git a/tests/wrappers.nims b/tests/wrappers.nims index 37ac686..4687d7a 100644 --- a/tests/wrappers.nims +++ b/tests/wrappers.nims @@ -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"
\ No newline at end of file + exec "../../../tests/timeit nimble install -d" + exec "../../../tests/timeit nimble test"
\ No newline at end of file |
