You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
617 B

  1. package benchmarks
  2. import (
  3. "testing"
  4. cmn "github.com/tendermint/tendermint/libs/common"
  5. )
  6. func BenchmarkSomething(b *testing.B) {
  7. b.StopTimer()
  8. numItems := 100000
  9. numChecks := 100000
  10. keys := make([]string, numItems)
  11. for i := 0; i < numItems; i++ {
  12. keys[i] = cmn.RandStr(100)
  13. }
  14. txs := make([]string, numChecks)
  15. for i := 0; i < numChecks; i++ {
  16. txs[i] = cmn.RandStr(100)
  17. }
  18. b.StartTimer()
  19. counter := 0
  20. for j := 0; j < b.N; j++ {
  21. foo := make(map[string]string)
  22. for _, key := range keys {
  23. foo[key] = key
  24. }
  25. for _, tx := range txs {
  26. if _, ok := foo[tx]; ok {
  27. counter++
  28. }
  29. }
  30. }
  31. }