mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
generate random txs
otherwise we're benchmarking overriding single key (because hash stays the same!)
This commit is contained in:
parent
788474d08d
commit
ff9d0cdfb6
@ -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…
x
Reference in New Issue
Block a user