From df405fd7de74768e3a989630e8558f897549626f Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 10 Jan 2025 20:00:06 -0800 Subject: [PATCH] Initial move to webpage for test output. --- test/CONFIG.mjs => test-tools.mjs | 2 + test.html | 80 +++++++++++++++++++++++++++++++ test/index.html | 17 ------- test/test.mjs | 60 ----------------------- 4 files changed, 82 insertions(+), 77 deletions(-) rename test/CONFIG.mjs => test-tools.mjs (98%) create mode 100644 test.html delete mode 100644 test/index.html delete mode 100644 test/test.mjs diff --git a/test/CONFIG.mjs b/test-tools.mjs similarity index 98% rename from test/CONFIG.mjs rename to test-tools.mjs index 7afb956..65c5c78 100644 --- a/test/CONFIG.mjs +++ b/test-tools.mjs @@ -227,3 +227,5 @@ export const assert = { } } } + +globalThis.TOOLING ??= { assert, average, print, random, skip, suite, test } diff --git a/test.html b/test.html new file mode 100644 index 0000000..0cf6041 --- /dev/null +++ b/test.html @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + +

nano-pow

+
+ + + diff --git a/test/index.html b/test/index.html deleted file mode 100644 index 3cb8c5d..0000000 --- a/test/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - diff --git a/test/test.mjs b/test/test.mjs deleted file mode 100644 index 41b1d93..0000000 --- a/test/test.mjs +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-FileCopyrightText: 20245Chris Duncan -// SPDX-License-Identifier: GPL-3.0-or-later - -'use strict' - -import { assert, average, print, random, skip, suite, test } from './CONFIG.mjs' -import { NanoPowGl, NanoPowGpu } from '../dist/main.min.js' - -await suite('Block performance', async () => { - const COUNT = 0xf - - await test(`NanoPowGpu: Calculate proof-of-work for ${COUNT} unique send block hashes`, async () => { - const times = [] - for (let i = 0; i < COUNT; i++) { - const hash = random() - const start = performance.now() - const work = await NanoPowGpu.search(hash) - const end = performance.now() - times.push(end - start) - console.log(`${work} (${end - start} ms) ${hash}`) - } - print(times) - }) - - await test(`NanoPowGl: Calculate proof-of-work for ${COUNT} unique send block hashes`, async () => { - const times = [] - for (let i = 0; i < COUNT; i++) { - const hash = random() - const start = performance.now() - const work = await NanoPowGl.search(hash) - const end = performance.now() - times.push(end - start) - console.log(`${work} (${end - start} ms) ${hash}`) - } - print(times) - }) - - await test(`nano-webgl-pow: Calculate proof-of-work for ${COUNT} unique send block hashes`, async () => { - //@ts-expect-error - window.NanoWebglPow.width = 256 * Math.max(1, Math.floor(navigator.hardwareConcurrency)) - //@ts-expect-error - window.NanoWebglPow.height = 256 * Math.max(1, Math.floor(navigator.hardwareConcurrency)) - const times = [] - for (let i = 0; i < COUNT; i++) { - const hash = random() - const start = performance.now() - const work = await new Promise(resolve => { - //@ts-expect-error - window.NanoWebglPow(hash, resolve, undefined, '0xFFFFFFF8') - }) - const end = performance.now() - times.push(end - start) - console.log(`${work} (${end - start} ms)`) - } - print(times) - }) -}) - -console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold') - -- 2.34.1