}
}
}
+
+globalThis.TOOLING ??= { assert, average, print, random, skip, suite, test }
--- /dev/null
+<!--
+SPDX-FileCopyrightText: 2025 2025 Chris Duncan <chris@zoso.dev>
+SPDX-License-Identifier: GPL-3.0-or-later
+-->
+
+<!DOCTYPE html>
+
+<head>
+ <link rel="icon" href="./favicon.ico">
+ <script type="module" src="./test-tools.mjs"></script>
+ <script type="module" src="../dist/global.min.js"></script>
+ <script type="module" src="https://cdn.jsdelivr.net/npm/nano-webgl-pow@1.1.1/nano-webgl-pow.js"></script>
+ <script type="module">
+ const { assert, average, print, random, skip, suite, test } = TOOLING
+ const { NanoPowGl, NanoPowGpu } = NanoPow
+
+ 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}`)
+ document.getElementById('output').innerHTML += `${hash} <${work}> (${end - start} ms)<br/>`
+ }
+ 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')
+
+
+ </script>
+ <style>body{background:black;color:white;}</style>
+</head>
+
+<body>
+ <h1>nano-pow</h1>
+ <div id="output"></pre>
+ </body>
+
+ </html>
+++ /dev/null
-<!--
-SPDX-FileCopyrightText: 2025 2025 Chris Duncan <chris@zoso.dev>
-SPDX-License-Identifier: GPL-3.0-or-later
--->
-
-<!DOCTYPE html>
-
-<head>
- <link rel="icon" href="./favicon.ico">
- <script type="module" src="./test.mjs"></script>
- <script type="module" src="https://cdn.jsdelivr.net/npm/nano-webgl-pow@1.1.1/nano-webgl-pow.js"></script>
- <style>body{background:black;}</style>
-</head>
-
-<body></body>
-
-</html>
+++ /dev/null
-// SPDX-FileCopyrightText: 20245Chris Duncan <chris@zoso.dev>
-// 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')
-