Skip to content

Commit

Permalink
Report averages
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Dec 18, 2019
1 parent 7b87b51 commit 0e13917
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nbench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ build/nbench cmdFullStateTransition -d=nbench/scenarios/mainnet/full_state_trans
build/nbench cmdSlotProcessing -d=tests/official/fixtures/tests-v0.9.2/mainnet/phase0/sanity/slots/pyspec_tests/slots_1
# Attestation processing
nbench/nbench cmdBlockProcessing --blockProcessingCat=catAttestations -d=tests/official/fixtures/tests-v0.9.2/mainnet/phase0/operations/attestation/pyspec_tests/success_multi_proposer_index_iterations/
build/nbench cmdBlockProcessing --blockProcessingCat=catAttestations -d=tests/official/fixtures/tests-v0.9.2/mainnet/phase0/operations/attestation/pyspec_tests/success_multi_proposer_index_iterations/
```

TODO Reporting:
Expand Down
17 changes: 12 additions & 5 deletions nbench/reports.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@ proc reportCli*(metrics: seq[Metadata], preset: string) =
# https://www.agner.org/optimize/blog/read.php?i=838
echo "The CPU Cycle Count is indicative only. It cannot be used to compare across systems, works at your CPU nominal frequency and is sensitive to overclocking, throttling and frequency scaling (powersaving and Turbo Boost)."

const lineSep = &"""|{'-'.repeat(50)}|{'-'.repeat(20)}|{'-'.repeat(20)}|{'-'.repeat(30)}|"""
const lineSep = &"""|{'-'.repeat(50)}|{'-'.repeat(14)}|{'-'.repeat(15)}|{'-'.repeat(17)}|{'-'.repeat(26)}|{'-'.repeat(26)}|"""
echo "\n"
echo lineSep
echo &"""|{"Procedures (" & preset & ')':^50}|{"# of Calls":^20}|{"Time (ms)":^20}|{"CPU cycles (in billions)":^30}|"""
echo &"""|{' '.repeat(50)}|{' '.repeat(20)}|{' '.repeat(20)}|{"indicative only":^30}|"""
echo &"""|{"Procedures (" & preset & ')':^50}|{"# of Calls":^14}|{"Time (ms)":^15}|{"Avg Time (ms)":^17}|{"CPU cycles (in billions)":^26}|{"Avg cycles (in billions)":^26}|"""
echo &"""|{' '.repeat(50)}|{' '.repeat(14)}|{' '.repeat(15)}|{' '.repeat(17)}|{"indicative only":^26}|{"indicative only":^26}|"""
echo lineSep
for m in metrics:
if m.numCalls == 0: continue
echo &"""|{m.procName:>50}|{m.numCalls:>20}|{m.cumulatedTimeNs.float64 * 1e-6:>20.3f}|{m.cumulatedCycles.float64 * 1e-9:>30.3f}|"""
if m.numCalls == 0:
continue
# TODO: running variance / standard deviation but the Welford method is quite costly.
# https://nim-lang.org/docs/stats.html / https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
let cumulTimeMs = m.cumulatedTimeNs.float64 * 1e-6
let avgTimeMs = cumulTimeMs / m.numCalls.float64
let cumulCyclesBillions = m.cumulatedCycles.float64 * 1e-9
let avgCyclesBillions = cumulCyclesBillions / m.numCalls.float64
echo &"""|{m.procName:<50}|{m.numCalls:>14}|{cumulTimeMs:>15.3f}|{avgTimeMs:>17.3f}|{cumulCyclesBillions:>26.3f}|{avgCyclesBillions:>26.3f}|"""
echo lineSep

0 comments on commit 0e13917

Please sign in to comment.