diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-06 21:08:45 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-06 21:08:45 -0700 |
| commit | c5a5b24cf6370ab549c033b20ad0389ec3ce8ec1 (patch) | |
| tree | dfd8b0914e2021fdd75e65c1db1beadbb51f74d9 /tools/finditers/finditers.go | |
| parent | Remove timeouts (diff) | |
| download | roseh.moe-c5a5b24cf6370ab549c033b20ad0389ec3ce8ec1.tar.zst | |
Simplify simplify simplify
Diffstat (limited to 'tools/finditers/finditers.go')
| -rw-r--r-- | tools/finditers/finditers.go | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/tools/finditers/finditers.go b/tools/finditers/finditers.go deleted file mode 100644 index 31a7e33..0000000 --- a/tools/finditers/finditers.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "encoding/hex" - "fmt" - "sort" - "testing" - "time" - - "gitlab.com/rhogenson/roseh.moe/internal/pwhash" -) - -func mustHex(t testing.TB, s string) []byte { - t.Helper() - b, err := hex.DecodeString(s) - if err != nil { - t.Fatalf("Invalid hex %q: %s", s, err) - } - return b -} - -var iterations int - -func BenchmarkHashIter(b *testing.B) { - const pw = "atypical evasion foyer roulette throng awning stability exchange humorless vowed" - salt := mustHex(b, "4250af599e07cde7") - for b.Loop() { - pwhash.HashIter(pw, salt, iterations) - } -} - -func main() { - const targetDuration = 5 * time.Second - for iterations = 4096; 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 - })) -} |
