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.

34 lines
597 B

8 years ago
  1. package benchmarks
  2. import (
  3. . "github.com/tendermint/tmlibs/common"
  4. "testing"
  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] = RandStr(100)
  13. }
  14. txs := make([]string, numChecks)
  15. for i := 0; i < numChecks; i++ {
  16. txs[i] = 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. }