From 5237291072c19a8f07b47162b7a9a86a1d1a21b2 Mon Sep 17 00:00:00 2001 From: jae beller Date: Sat, 29 Mar 2025 23:38:12 -0400 Subject: Debug tool for benchmarking proof-of-work algorithms (#155) * cmd/anubis: add a debug option for benchmarking hashrate Having the ability to benchmark different proof-of-work implementations is useful for extending Anubis. This adds a flag `--debug-benchmark-js` (and its associated environment variable `DEBUG_BENCHMARK_JS`) for serving a tool to do so. Internally, a there is a new policy action, "DEBUG_BENCHMARK", which serves the benchmarking tool instead of a challenge. The flag then replaces all bot rules with a special rule matching every request to that action. The benchmark page makes heavy use of inline styles, because currently all global styles are shared across all pages. This could be fixed, but I wanted to avoid major changes to the templates. * web/js: add signal for aborting an active proof-of-work algorithm Both proof-of-work algorithms now take an optional `AbortSignal`, which immediately terminates all workers and returns `false` if aborted before the challenge is complete. * web/js: add algorithm comparison to the benchmark page "Compare:" is added to the benchmark page for testing the relative performance between two algorithms. Since benchmark runs generally have high variance, it may take a while for the averages to converge on a stable difference. --------- Signed-off-by: Xe Iaso Co-authored-by: Xe Iaso --- web/index.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'web/index.go') diff --git a/web/index.go b/web/index.go index 7057cc8..6ef84b5 100644 --- a/web/index.go +++ b/web/index.go @@ -13,3 +13,7 @@ func Index() templ.Component { func ErrorPage(msg string) templ.Component { return errorPage(msg) } + +func Bench() templ.Component { + return bench() +} -- cgit v1.2.3