From: Chris Duncan Date: Sat, 11 Jan 2025 04:00:06 +0000 (-0800) Subject: Initial move to webpage for test output. X-Git-Tag: v0.0.1~11 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=df405fd7de74768e3a989630e8558f897549626f;p=nano-pow.git Initial move to webpage for test output. --- 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') -