-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1140 from Agoric/perf-tools
Add simple stats dumping capability to swingset runner and kernel dumper
- Loading branch information
Showing
6 changed files
with
76 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const log = console.log; | ||
|
||
export function printStats(stats, cranks) { | ||
const wk = 32; | ||
const wi = 9; | ||
const wf = 8; | ||
|
||
const h1 = `${'Stat'.padEnd(wk)}`; | ||
const d1 = `${''.padEnd(wk, '-')}`; | ||
|
||
const h2 = `${'Value'.padStart(wi)}`; | ||
const d2 = ` ${''.padStart(wi - 1, '-')}`; | ||
|
||
const h3 = `${'MaxValue'.padStart(wi)}`; | ||
const d3 = ` ${''.padStart(wi - 1, '-')}`; | ||
|
||
const h4 = ` ${'PerCrank'.padStart(wf)}`; | ||
const d4 = ` ${''.padStart(wf, '-')}`; | ||
|
||
log(`In ${cranks} cranks:`); | ||
log(`${h1} ${h2} ${h3} ${h4}`); | ||
log(`${d1} ${d2} ${d3} ${d4}`); | ||
|
||
for (const [key, value] of Object.entries(stats)) { | ||
if (!key.endsWith('Max')) { | ||
const maxKey = `${key}Max`; | ||
const col1 = `${key.padEnd(wk)}`; | ||
const col2 = `${String(value).padStart(wi)}`; | ||
const v3 = stats[maxKey] !== undefined ? stats[maxKey] : ''; | ||
const col3 = `${String(v3).padStart(wi)}`; | ||
const col4 = `${String((value / cranks).toFixed(4)).padStart(wf)}`; | ||
log(`${col1} ${col2} ${col3} ${col4}`); | ||
} | ||
} | ||
} |