diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-05 18:00:06 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-05 18:00:06 -0700 |
| commit | d89b325294201d95498ae9d08f102e12ac2f2876 (patch) | |
| tree | ffe65e33d0d01e811a5323d5e40c47564ccb8f2d /tools/finditers | |
| parent | Allow downloading without gob (diff) | |
| download | roseh.moe-d89b325294201d95498ae9d08f102e12ac2f2876.tar.zst | |
Implement a "magic wormhole" file-sharing solution
Diffstat (limited to 'tools/finditers')
| -rw-r--r-- | tools/finditers/finditers.go | 53 |
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) - } -} |
