mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 21:01:21 +00:00
Tendermint <-> Application refactor
This commit is contained in:
39
benchmarks/map_test.go
Normal file
39
benchmarks/map_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
. "github.com/tendermint/go-common"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkSomething(b *testing.B) {
|
||||
b.StopTimer()
|
||||
numItems := 100000
|
||||
numChecks := 100000
|
||||
keys := make([]string, numItems)
|
||||
for i := 0; i < numItems; i++ {
|
||||
keys[i] = RandStr(32)
|
||||
}
|
||||
txs := make([]string, numChecks)
|
||||
for i := 0; i < numChecks; i++ {
|
||||
txs[i] = RandStr(32)
|
||||
}
|
||||
b.StartTimer()
|
||||
|
||||
counter := 0
|
||||
for j := 0; j < b.N; j++ {
|
||||
foo := make(map[string]string)
|
||||
for _, key := range keys {
|
||||
foo[key] = key
|
||||
}
|
||||
for _, tx := range txs {
|
||||
if _, ok := foo[tx]; ok {
|
||||
counter++
|
||||
}
|
||||
}
|
||||
for _, tx := range txs {
|
||||
if _, ok := foo[tx]; ok {
|
||||
counter++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user