summaryrefslogtreecommitdiffstats
path: root/tools/finditer/finditer.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/finditer/finditer.go')
-rw-r--r--tools/finditer/finditer.go43
1 files changed, 0 insertions, 43 deletions
diff --git a/tools/finditer/finditer.go b/tools/finditer/finditer.go
deleted file mode 100644
index 114785d..0000000
--- a/tools/finditer/finditer.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package main
-
-import (
- "encoding/hex"
- "fmt"
- "sort"
- "testing"
- "time"
-
- "roseh.moe/pkg/roseh.moe/internal/pwhash"
-)
-
-func mustHex(s string) []byte {
- b, err := hex.DecodeString(s)
- if err != nil {
- panic(err)
- }
- return b
-}
-
-const password = "emcee polio cardiac disclose superglue clapper cruelness stonework tingly unarmored"
-
-var salt = mustHex("a0aa6971f38827e5")
-
-var iterations int
-
-func BenchmarkHashIter(b *testing.B) {
- for b.Loop() {
- pwhash.HashIter(password, salt, iterations)
- }
-}
-
-func main() {
- const targetDuration = 5 * time.Second
- for iterations = 8192; time.Duration(testing.Benchmark(BenchmarkHashIter).NsPerOp()) < targetDuration; iterations *= 2 {
- }
- lo := iterations / 2
- hi := iterations
- fmt.Println(lo + sort.Search(hi-lo, func(i int) bool {
- iterations = lo + i
- return time.Duration(testing.Benchmark(BenchmarkHashIter).NsPerOp()) > targetDuration
- }))
-}