]> zoso.dev Git - libnemo.git/commitdiff
Benchmark min and max times, and add another round of testing.
authorChris Duncan <chris@zoso.dev>
Mon, 6 Jan 2025 19:24:02 +0000 (11:24 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 6 Jan 2025 19:24:02 +0000 (11:24 -0800)
GLOBALS.mjs
benchmarks.md
perf/block.perf.js

index 0b02fc92adac9b584d3eaa9a8d5f1a3238536b49..c6fab27732eb2e5a6af4dd1ad69e3a4dce5db1c4 100644 (file)
@@ -17,17 +17,21 @@ if (globalThis.sessionStorage == null) {
 }
 
 export function average (times) {
-       let sum = 0, reciprocals = 0, product = 1, count = times.length
+       let sum = 0, reciprocals = 0, product = 1, count = times.length, min = 0xffff, max = 0
        for (let i = 0; i < count; i++) {
                sum += times[i]
                reciprocals += 1 / times[i]
                product *= times[i]
+               min = Math.min(min, times[i])
+               max = Math.max(max, times[i])
        }
        return {
                total: sum,
                arithmetic: sum / count,
                harmonic: count / reciprocals,
-               geometric: Math.pow(product, 1 / count)
+               geometric: Math.pow(product, 1 / count),
+               min: min,
+               max: max
        }
 }
 
@@ -57,7 +61,7 @@ await suite('TEST RUNNER CHECK', async () => {
        console.assert(failures.some(call => /.*promise should fail.*/.test(call[0])) === true, `bad promise not errored`)
        console.assert(passes.some(call => /.*promise should fail.*/.test(call[0])) === false, 'bad promise logged')
 
-       await test('async should pass', async () => { })
+       await test('async should pass', async () => {})
        console.assert(failures.some(call => /.*async should pass.*/.test(call[0])) === false, 'good async errored')
        console.assert(passes.some(call => /.*async should pass.*/.test(call[0])) === true, 'good async not logged')
 
@@ -65,7 +69,7 @@ await suite('TEST RUNNER CHECK', async () => {
        console.assert(failures.some(call => /.*async should fail.*/.test(call[0])) === true, 'bad async not errored')
        console.assert(passes.some(call => /.*async should fail.*/.test(call[0])) === false, 'bad async logged')
 
-       await test('function should pass', () => { })
+       await test('function should pass', () => {})
        console.assert(failures.some(call => /.*function should pass.*/.test(call[0])) === false, 'good function errored')
        console.assert(passes.some(call => /.*function should pass.*/.test(call[0])) === true, 'good function not logged')
 
index 30d20bdeb1e98cbaac5003b9eb303e4c929baae6..7407db4b2d0bf714a5e27d8d382fedad0f0e49c2 100644 (file)
@@ -29,6 +29,7 @@ Geometric: Infinity ms block.perf.js:59:10
 PASS  Customized PoW: Time to calculate proof-of-work for a send block 512 times
 
 
+/media/plex/Shows/STAR_TREK_DISCOVERY_S1_D1/STAR_TREK_DISCOVERY (Season 1 Disc 1)
 
 CHROMIUM with more accurate timings
 
@@ -37,3 +38,9 @@ Average: 366.07109375001164 ms
 Harmonic: 220.70399520519166 ms
 Geometric: Infinity ms
 Customized PoW: Time to calculate proof-of-work for a send block 512 times
+
+Total: 187827.7999998629 ms
+block.perf.js:57 Average: 366.85117187473224 ms
+block.perf.js:58 Harmonic: 223.9897252426498 ms
+block.perf.js:59 Geometric: Infinity ms
+GLOBALS.mjs:42 PASS  Customized PoW: Time to calculate proof-of-work for a send block 512 times
index 555eac638abafc61d8ff66b0ed91020064f24532..e2deeb7fdba06cf95ae09e48aca55c0095f47014 100644 (file)
@@ -28,11 +28,13 @@ await suite('Block performance', async () => {
                        times.push(end - start)
                        console.log(`${work} (${end - start} ms) ${hashes[i]}`)
                }
-               const { total, arithmetic, harmonic, geometric } = average(times)
+               const { total, arithmetic, harmonic, geometric, min, max } = average(times)
                console.log(`Total: ${total} ms`)
                console.log(`Average: ${arithmetic} ms`)
                console.log(`Harmonic: ${harmonic} ms`)
                console.log(`Geometric: ${geometric} ms`)
+               console.log(`Minimum: ${min} ms`)
+               console.log(`Maximum: ${max} ms`)
        })
 
        await test(`Customized PoW: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
@@ -52,11 +54,13 @@ await suite('Block performance', async () => {
                        times.push(end - start)
                        console.log(`${block.work} (${end - start} ms)`)
                }
-               const { total, arithmetic, harmonic, geometric } = average(times)
+               const { total, arithmetic, harmonic, geometric, min, max } = average(times)
                console.log(`Total: ${total} ms`)
                console.log(`Average: ${arithmetic} ms`)
                console.log(`Harmonic: ${harmonic} ms`)
                console.log(`Geometric: ${geometric} ms`)
+               console.log(`Minimum: ${min} ms`)
+               console.log(`Maximum: ${max} ms`)
        })
 
        await skip(`Original PoW module: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
@@ -71,10 +75,12 @@ await suite('Block performance', async () => {
                        times.push(end - start)
                        console.log(`${work} (${end - start} ms)`)
                }
-               const { total, arithmetic, harmonic, geometric } = average(times)
+               const { total, arithmetic, harmonic, geometric, min, max } = average(times)
                console.log(`Total: ${total} ms`)
                console.log(`Average: ${arithmetic} ms`)
                console.log(`Harmonic: ${harmonic} ms`)
                console.log(`Geometric: ${geometric} ms`)
+               console.log(`Minimum: ${min} ms`)
+               console.log(`Maximum: ${max} ms`)
        })
 })