summary refs log tree commit diff stats
path: root/examples/cgi/cgi_server.py
blob: 1907515e80f7be62a6e5ea88862997597beb3a90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env python
import BaseHTTPServer
import CGIHTTPServer

server = BaseHTTPServer.HTTPServer
handler = CGIHTTPServer.CGIHTTPRequestHandler
server_address = ('localhost', 8008)
handler.cgi_directories = ['/']

httpd = server(server_address, handler)
httpd.serve_forever()
">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))