summaryrefslogtreecommitdiff
path: root/bin/rtt-fuzz-rand
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-04-28 22:09:29 +0200
committerTor Andersson <tor@ccxvii.net>2025-04-29 01:16:25 +0200
commit48e39e44dbe267f8945e9d597e61fd8aa3dfb376 (patch)
treec75e854fadc20d827cd5b422c5ab0f1a45cdf1d2 /bin/rtt-fuzz-rand
parent7a93787dfe5cdaba3eed98ed8edd19674186430b (diff)
downloadserver-48e39e44dbe267f8945e9d597e61fd8aa3dfb376.tar.gz
Improved fuzzing.
Diffstat (limited to 'bin/rtt-fuzz-rand')
-rwxr-xr-xbin/rtt-fuzz-rand32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/rtt-fuzz-rand b/bin/rtt-fuzz-rand
new file mode 100755
index 0000000..38878c3
--- /dev/null
+++ b/bin/rtt-fuzz-rand
@@ -0,0 +1,32 @@
+#!/usr/bin/env -S node
+
+"use strict"
+
+const fs = require("fs")
+const crypto = require("crypto")
+
+if (process.argv.length < 3) {
+ console.error("rtt-fuzz-rand TITLE")
+ process.exit(1)
+}
+
+process.env.TITLE = process.argv[2]
+
+const { fuzz } = require("../tools/fuzz.js")
+
+fs.mkdir("fuzzer", ()=>{})
+
+if (process.argv.length > 3) {
+ fuzz(parseInt(process.argv[3]))
+} else {
+ // run for an hour-ish
+ var i, n, a, b
+ for (i = 0; i < 3600; ++i) {
+ a = b = Date.now()
+ for (n = 0; b < a + 5_000; ++n) {
+ fuzz(crypto.randomInt(1, 2**48))
+ b = Date.now()
+ }
+ console.log("# " + Math.round( (1000 * n) / (b-a) ) + " runs/second")
+ }
+}