Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async closure timings #512

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.nims
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
mkDir "build"
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
var extra_params = params
when compiles(commandLineParams):
when compiles(commandLineParams()):
for param in commandLineParams():
extra_params &= " " & param
else:
Expand Down
2 changes: 2 additions & 0 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ include "build.nims"
import std/os
const currentDir = currentSourcePath()[0 .. ^(len("config.nims") + 1)]

--d:chronosClosureDurationMetric

when getEnv("NIMBUS_BUILD_SYSTEM") == "yes" and
# BEWARE
# In Nim 1.6, config files are evaluated with a working directory
Expand Down
28 changes: 28 additions & 0 deletions tests/testCodex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,31 @@ import ./codex/testvalidation
import ./codex/testasyncstreamwrapper

{.warning[UnusedImport]: off.}

when isMainModule and defined(chronosClosureDurationMetric):
import std/tables
import chronos

let metrics = getCallbackDurations()
echo "\ncsv timings print: "
echo "file, ", "line, ", "procedure, ", "count, ", "avg micros, ", "min, ", "max, ", "total "

for (k,v) in metrics.pairs():
if v.count > 0:
let avgMicros = microseconds(v.totalDuration div v.count)
let minMicros = microseconds(v.minSingleTime)
let maxMicros = microseconds(v.maxSingleTime)
let totalMicros = microseconds(v.totalDuration)
echo k.file, ", ", k.line, ", ", k.procedure, ", ", v.count, ", ",
avgMicros, ", ", minMicros, ", ", maxMicros, ", ", totalMicros

echo "\nflat print: "
for (k,v) in metrics.pairs():
if v.count > 0:
echo ""
echo "metric: ", $k
echo "count: ", v.count
echo "min: ", v.minSingleTime
echo "avg: ", v.totalDuration div v.count
echo "max: ", v.maxSingleTime
echo "total: ", v.totalDuration
28 changes: 28 additions & 0 deletions tests/testIntegration.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,31 @@ import ./integration/testblockexpiration
import ./integration/testproofs

{.warning[UnusedImport]:off.}

when isMainModule and defined(chronosClosureDurationMetric):
import std/tables
import chronos

let metrics = getCallbackDurations()
echo "\ncsv timings print: "
echo "file, ", "line, ", "procedure, ", "count, ", "avg micros, ", "min, ", "max, ", "total "

for (k,v) in metrics.pairs():
if v.count > 0:
let avgMicros = microseconds(v.totalDuration div v.count)
let minMicros = microseconds(v.minSingleTime)
let maxMicros = microseconds(v.maxSingleTime)
let totalMicros = microseconds(v.totalDuration)
echo k.file, ", ", k.line, ", ", k.procedure, ", ", v.count, ", ",
avgMicros, ", ", minMicros, ", ", maxMicros, ", ", totalMicros

echo "\nflat print: "
for (k,v) in metrics.pairs():
if v.count > 0:
echo ""
echo "metric: ", $k
echo "count: ", v.count
echo "min: ", v.minSingleTime
echo "avg: ", v.totalDuration div v.count
echo "max: ", v.maxSingleTime
echo "total: ", v.totalDuration