]> zoso.dev Git - nano-pow.git/commitdiff
Restore basic performance timing to CLI when debugging.
authorChris Duncan <chris@zoso.dev>
Thu, 13 Mar 2025 16:54:05 +0000 (09:54 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 13 Mar 2025 16:54:05 +0000 (09:54 -0700)
cli.js

diff --git a/cli.js b/cli.js
index d066556246587a9035adf7c4961c984f6540451a..ab7f6642450464aed5fdc5c507470379ca55b548 100755 (executable)
--- a/cli.js
+++ b/cli.js
@@ -97,10 +97,14 @@ if (options['debug']) console.log(`${fn} options`, JSON.stringify(options))
        const page = await browser.newPage()
        await page.setBypassCSP(true)
        await page.goto('chrome://terms')
+
+       let start = performance.now()
        page.on('console', async (msg) => {
                const output = msg.text().split(' ')
                if (output[0] === 'cli') {
                        if (output[1] === 'exit') {
+                               const end = performance.now()
+                               if (options['debug']) console.log(end - start, 'ms total |', (end - start) / hashes.length, 'ms avg')
                                process.exit()
                        } else {
                                console.log(output[1])
@@ -112,6 +116,7 @@ if (options['debug']) console.log(`${fn} options`, JSON.stringify(options))
        await page.waitForFunction(async () => {
                return await navigator.gpu.requestAdapter()
        })
+       start = performance.now()
        await page.addScriptTag({
                type: 'module',
                content: `