Browse Source

generate random txs

otherwise we're benchmarking overriding single key (because hash stays
the same!)
pull/2337/head
Anton Kaliaev 6 years ago
parent
commit
ff9d0cdfb6
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 15 additions and 15 deletions
  1. +15
    -15
      state/txindex/kv/kv_test.go

+ 15
- 15
state/txindex/kv/kv_test.go View File

@ -190,34 +190,34 @@ func txResultWithTags(tags []cmn.KVPair) *types.TxResult {
}
func benchmarkTxIndex(txsCount int64, b *testing.B) {
tx := types.Tx("HELLO WORLD")
txResult := &types.TxResult{
Height: 1,
Index: 0,
Tx: tx,
Result: abci.ResponseDeliverTx{
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
Tags: []cmn.KVPair{},
},
}
dir, err := ioutil.TempDir("", "tx_index_db")
if err != nil {
b.Fatal(err)
}
defer os.RemoveAll(dir) // nolint: errcheck
store := db.NewDB("tx_index", "leveldb", dir)
store := db.NewDB("tx_index", "bboltdb", dir)
indexer := NewTxIndex(store)
batch := txindex.NewBatch(txsCount)
txIndex := uint32(0)
for i := int64(0); i < txsCount; i++ {
tx := cmn.RandBytes(250)
txResult := &types.TxResult{
Height: 1,
Index: txIndex,
Tx: tx,
Result: abci.ResponseDeliverTx{
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
Tags: []cmn.KVPair{},
},
}
if err := batch.Add(txResult); err != nil {
b.Fatal(err)
}
txResult.Index++
txIndex++
}
b.ResetTimer()


Loading…
Cancel
Save