mirror of
https://github.com/badges/shields.git
synced 2025-04-18 19:44:04 +03:00
* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * reformat all the things (prettier 3) * update tests to await calls to prettier.format() --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: chris48s <git@chris-shaw.dev>
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import readline from 'readline'
|
|
import minimist from 'minimist'
|
|
|
|
async function captureTimings(warmupIterations) {
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
})
|
|
|
|
const times = {}
|
|
let timingsCount = 0
|
|
let labelsCount = 0
|
|
const timing = /^(.+): ([0-9.]+)ms$/i
|
|
|
|
for await (const line of rl) {
|
|
const match = timing.exec(line)
|
|
if (match) {
|
|
labelsCount = Object.keys(times).length
|
|
if (timingsCount > warmupIterations * labelsCount) {
|
|
const label = match[1]
|
|
const time = parseFloat(match[2])
|
|
times[label] = time + (times[label] || 0)
|
|
}
|
|
++timingsCount
|
|
}
|
|
}
|
|
return { times, iterations: timingsCount / labelsCount }
|
|
}
|
|
|
|
function logResults({ times, iterations, warmupIterations }) {
|
|
if (isNaN(iterations)) {
|
|
console.log(
|
|
'No timings captured. Have you included console.time statements in the badge creation code path?',
|
|
)
|
|
} else {
|
|
const timedIterations = iterations - warmupIterations
|
|
for (const [label, time] of Object.entries(times)) {
|
|
const averageTime = time / timedIterations
|
|
console.log(
|
|
`Average '${label}' time over ${timedIterations} iterations: ${averageTime}ms`,
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const args = minimist(process.argv)
|
|
const warmupIterations = parseInt(args['warmup-iterations']) || 100
|
|
const { times, iterations } = await captureTimings(warmupIterations)
|
|
logResults({ times, iterations, warmupIterations })
|
|
}
|
|
|
|
;(async () => {
|
|
try {
|
|
await main()
|
|
} catch (e) {
|
|
console.error(e)
|
|
process.exit(1)
|
|
}
|
|
})()
|