Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save henriquechehad/c66191032423c2927654c1bd760d2caa to your computer and use it in GitHub Desktop.
Save henriquechehad/c66191032423c2927654c1bd760d2caa to your computer and use it in GitHub Desktop.
bcrypt benchmark test 2
package main
import (
"sync"
"testing"
"golang.org/x/crypto/bcrypt"
)
func BenchmarkBCryptCompareHashAndPassword(b *testing.B) {
var wg sync.WaitGroup
for i := 0; i <= 500; i++ {
wg.Add(1)
go func() {
defer wg.Done()
err := bcrypt.CompareHashAndPassword([]byte("$2a$10$Q1bGQ4ERi4Zj.slbReOjOu0/T.2MhLCX9ASvCQqfh1LgbdRLdO6o6"), []byte("12345678"))
if err != nil {
b.Errorf("error on compare: %v", err)
}
}()
}
wg.Wait()
b.Log("Done")
}
=============
Result:
$ go tool pprof mem.out
Type: inuse_space
Time: Jul 5, 2018 at 11:26am (BRT)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 0, 0% of 0 total
flat flat% sum% cum cum%
(pprof)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment