|
@ -190,34 +190,34 @@ func txResultWithTags(tags []cmn.KVPair) *types.TxResult { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func benchmarkTxIndex(txsCount int64, b *testing.B) { |
|
|
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") |
|
|
dir, err := ioutil.TempDir("", "tx_index_db") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
b.Fatal(err) |
|
|
b.Fatal(err) |
|
|
} |
|
|
} |
|
|
defer os.RemoveAll(dir) // nolint: errcheck
|
|
|
defer os.RemoveAll(dir) // nolint: errcheck
|
|
|
|
|
|
|
|
|
store := db.NewDB("tx_index", "leveldb", dir) |
|
|
|
|
|
|
|
|
store := db.NewDB("tx_index", "bboltdb", dir) |
|
|
indexer := NewTxIndex(store) |
|
|
indexer := NewTxIndex(store) |
|
|
|
|
|
|
|
|
batch := txindex.NewBatch(txsCount) |
|
|
batch := txindex.NewBatch(txsCount) |
|
|
|
|
|
txIndex := uint32(0) |
|
|
for i := int64(0); i < txsCount; i++ { |
|
|
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 { |
|
|
if err := batch.Add(txResult); err != nil { |
|
|
b.Fatal(err) |
|
|
b.Fatal(err) |
|
|
} |
|
|
} |
|
|
txResult.Index++ |
|
|
|
|
|
|
|
|
txIndex++ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
b.ResetTimer() |
|
|
b.ResetTimer() |
|
|