From: Chris Duncan Date: Mon, 16 Jun 2025 17:51:39 +0000 (-0700) Subject: Generate one zero-difficulty nonce to compile. Add parameters from page to score... X-Git-Tag: v5.0.0~13 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8a30ac570a6c0cb7026f22a6e3aa92abe3639b2b;p=nano-pow.git Generate one zero-difficulty nonce to compile. Add parameters from page to score function. Reorganize options section. --- diff --git a/test/index.html b/test/index.html index d072fe7..ca0a5b7 100644 --- a/test/index.html +++ b/test/index.html @@ -52,7 +52,9 @@ SPDX-License-Identifier: GPL-3.0-or-later } } - export async function run (difficulty, size, effort, isOutputShown, api, isDebug, isSelfCheck) { + export async function run (size, difficulty, effort, api, isOutputShown, isDebug, isSelfCheck) { + // Generate once on load to compile shaders and initialize buffers + await NanoPow.work_generate(random(), { api, difficulty: 0 }) const type = api api = type.toLowerCase() if (isSelfCheck) { @@ -175,18 +177,18 @@ SPDX-License-Identifier: GPL-3.0-or-later console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold') } - export async function score () { + export async function score (runs, size, difficulty, effort, api) { const rates = [] - for (let i = 0; i < 100; i++) { + for (let i = 0; i < runs; i++) { const times = [] - console.log(`%cNanoPow`, 'color:green', `Calculate proof-of-work for 1000 unique send block hashes`) - for (let j = 0; j < 100; j++) { - document.getElementById('status').innerHTML = `SCORING IN PROGRESS. THIS WILL TAKE A LONG TIME. ${i}/100 ${j}/1000
` + console.log(`%cNanoPow ${api}`, 'color:green', `Calculate proof-of-work for ${runs} unique send block hashes`) + for (let j = 0; j < size; j++) { + document.getElementById('status').innerHTML = `SCORING IN PROGRESS. THIS WILL TAKE A LONG TIME. ${i}/${size} ${j}/${runs}
` const hash = random() let result = null const start = performance.now() try { - result = await NanoPow.work_generate(hash) + result = await NanoPow.work_generate(hash, { difficulty, effort, api }) } catch (err) { document.getElementById('output').innerHTML += `Error: ${err.message}
` console.error(err) @@ -199,14 +201,14 @@ SPDX-License-Identifier: GPL-3.0-or-later console.log(results) const { truncatedRate } = results rates.push(truncatedRate) - document.getElementById('output').innerHTML += `Truncated Rate ${i}: ${truncatedRate}
` + document.getElementById('output').innerHTML += `Benchmark ${i + 1} score: ${truncatedRate} wps
` } const results = Object.values(average(rates))[0] console.log(rates) console.log(results) const { truncatedHarmonic } = results document.getElementById('output').innerHTML += `
` - document.getElementById('summary').innerHTML += `Score: ${truncatedHarmonic} wps
` + document.getElementById('summary').innerHTML += `work-per-second: ${truncatedHarmonic}
` document.getElementById('status').innerHTML = `SCORING COMPLETE
` console.log('%cSCORING COMPLETE', 'color:orange;font-weight:bold') } @@ -245,14 +247,14 @@ SPDX-License-Identifier: GPL-3.0-or-later function startTest (event) { event.target.disabled = true - const difficulty = document.getElementById('difficulty') const size = document.getElementById('size') + const difficulty = document.getElementById('difficulty') const effort = document.getElementById('effort') - const isOutputShown = document.getElementById('isOutputShown') const api = document.getElementById('api') + const isOutputShown = document.getElementById('isOutputShown') const isDebug = document.getElementById('isDebug') const isSelfCheck = document.getElementById('isSelfCheck') - run(difficulty.value, +size.value, +effort.value, isOutputShown.checked, api.value, isDebug.checked, isSelfCheck.checked) + run(+size.value, difficulty.value, +effort.value, api.value, isOutputShown.checked, isDebug.checked, isSelfCheck.checked) .then(() => { event.target.disabled = false isSelfCheck.checked = false @@ -261,7 +263,14 @@ SPDX-License-Identifier: GPL-3.0-or-later function startScore (event) { event.target.disabled = true - score().then(() => event.target.disabled = false) + const runs = document.getElementById('runs') + const size = document.getElementById('size') + const difficulty = document.getElementById('difficulty') + const effort = document.getElementById('effort') + const api = document.getElementById('api') + const isOutputShown = document.getElementById('isOutputShown') + score(+runs.value, +size.value, difficulty.value, +effort.value, api.value, isOutputShown.checked) + .then(() => event.target.disabled = false) } document.getElementById('btnStartTest').addEventListener('click', startTest) @@ -269,10 +278,11 @@ SPDX-License-Identifier: GPL-3.0-or-later document.getElementById('effort').value = Math.max(1, Math.floor(navigator.hardwareConcurrency) / 2) @@ -285,15 +295,15 @@ SPDX-License-Identifier: GPL-3.0-or-later

Times below are in milliseconds and are summarized by various averaging methods.

Level of Effort depends on hardware and does not guarantee faster results.


- - -
- - + +
- +

+

Options

+ +
@@ -307,6 +317,8 @@ SPDX-License-Identifier: GPL-3.0-or-later +
+

Benchmarking

@@ -321,7 +333,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
+

Scoring

+ + +

WAITING