summaryrefslogtreecommitdiffstats
path: root/tools/finditers
diff options
context:
space:
mode:
Diffstat (limited to 'tools/finditers')
-rw-r--r--tools/finditers/finditers.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/tools/finditers/finditers.go b/tools/finditers/finditers.go
deleted file mode 100644
index 746242b..0000000
--- a/tools/finditers/finditers.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package main
-
-import (
- "fmt"
- "math/rand/v2"
- "os"
- "sort"
- "testing"
- "time"
-
- "gitlab.com/rhogenson/roseh.moe/internal/cryptoutil"
-)
-
-var (
- iterations int
-
- salt = func() []byte {
- r := rand.New(new(rand.PCG))
- salt := make([]byte, cryptoutil.SaltSize)
- for i := range salt {
- salt[i] = byte(r.IntN(256))
- }
- return salt
- }()
-)
-
-func BenchmarkHashIter(b *testing.B) {
- const password = "oboe shortness ether ideology undesired fresh freezable catching mashing glimpse"
- for b.Loop() {
- cryptoutil.HashIter(password, salt, iterations)
- }
-}
-
-func run() error {
- const targetDuration = 2 * 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
- }))
- return nil
-}
-
-func main() {
- if err := run(); err != nil {
- fmt.Fprintln(os.Stderr, err)
- os.Exit(1)
- }
-}