diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-12-12 16:29:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 16:29:46 +0100 |
commit | a1bf9fd2b6525e613899c5dc0380fb80021ee3e7 (patch) | |
tree | d2bdb332c973d2f6d43391369229cc732642c74d /tests/benchmark.nim | |
parent | a38f35359738534ba856d02f3564d5fbc2dfc822 (diff) | |
parent | 070bcf4cea28a3238089379f5884787b2084b2de (diff) | |
download | Nim-a1bf9fd2b6525e613899c5dc0380fb80021ee3e7.tar.gz |
Merge branch 'devel' into sorted_deduplicate
Diffstat (limited to 'tests/benchmark.nim')
-rw-r--r-- | tests/benchmark.nim | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/tests/benchmark.nim b/tests/benchmark.nim deleted file mode 100644 index 69c9a3927..000000000 --- a/tests/benchmark.nim +++ /dev/null @@ -1,47 +0,0 @@ -# -# -# Nim Benchmark tool -# (c) Copyright 2012 Dominik Picheta -# -# See the file "copying.txt", included in this -# distribution, for details about the copyright. -# - -## This program runs benchmarks -import osproc, os, times, json - -type - TBenchResult = tuple[file: string, success: bool, time: float] - -proc compileBench(file: string) = - ## Compiles ``file``. - doAssert(execCmdEx("nim c -d:release " & file).exitCode == QuitSuccess) - -proc runBench(file: string): TBenchResult = - ## Runs ``file`` and returns info on how long it took to run. - var start = epochTime() - if execCmdEx(file.addFileExt(ExeExt)).exitCode == QuitSuccess: - var t = epochTime() - start - result = (file, true, t) - else: result = (file, false, -1.0) - -proc genOutput(benches: seq[TBenchResult]): PJsonNode = - result = newJObject() - for i in benches: - if i.success: - result[i.file.extractFilename] = newJFloat(i.time) - else: - result[i.file.extractFilename] = newJNull() - -proc doBench(): seq[TBenchResult] = - result = @[] - for i in walkFiles("tests/benchmarks/*.nim"): - echo(i.extractFilename) - compileBench(i) - result.add(runBench(i)) - -when isMainModule: - var b = doBench() - var output = genOutput(b) - writeFile("benchmarkResults.json", pretty(output)) - |