Created
November 9, 2022 21:31
-
-
Save victusfate/1329f0a1a8baf639b2f96d1be7cfb710 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const fs = require('fs') | |
if (process.argc < 3) { | |
console.log('Usage: node timing.js <filename>') | |
process.exit(1) | |
} | |
const sFile = process.argv[2] | |
console.log({sFile}) | |
const dataStrings = fs.readFileSync(sFile,'utf8').split('\n') | |
const data = [] | |
for(let sData of dataStrings) { | |
try { | |
data.push(JSON.parse(sData)) | |
} | |
catch(err) { | |
// console.log(err) | |
} | |
} | |
let stats = {} | |
for (let d of data) { | |
let sAction = d['--action'] | |
if ('--ms' in d) { | |
if (sAction == 'ORM.Db.query') { | |
const name = d['ORM']?.['Db']?.['query']?.['name'] | |
if (name) { | |
sAction = sAction + '.' + name | |
} | |
} | |
const ms = parseFloat(d['--ms']) | |
if (!(sAction in stats)) { | |
stats[sAction] = 0 | |
} | |
// console.log({ action: sAction, ms: ms }) | |
stats[sAction] += ms | |
} | |
} | |
console.log(stats) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment