Skip to content

Commit

Permalink
BlockchainLMDB: Add profiling to tx_exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
warptangent committed Feb 23, 2015
1 parent 83fb6d8 commit 6485dac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,6 @@ uint64_t BlockchainLMDB::height() const
return m_height;
}


bool BlockchainLMDB::tx_exists(const crypto::hash& h) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
Expand All @@ -1144,7 +1143,11 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) const

MDB_val_copy<crypto::hash> key(h);
MDB_val result;

TIME_MEASURE_START(time1);
auto get_result = mdb_get(*txn_ptr, m_txs, &key, &result);
TIME_MEASURE_FINISH(time1);
time_tx_exists += time1;
if (get_result == MDB_NOTFOUND)
{
if (! m_batch_active)
Expand Down
3 changes: 3 additions & 0 deletions src/cryptonote_core/blockchain_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void BlockchainDB::reset_stats()
{
num_calls = 0;
time_blk_hash = 0;
time_tx_exists = 0;
time_add_block1 = 0;
time_add_transaction = 0;
time_commit1 = 0;
Expand All @@ -163,6 +164,8 @@ void BlockchainDB::show_stats()
<< ENDL
<< "time_blk_hash: " << time_blk_hash << "ms"
<< ENDL
<< "time_tx_exists: " << time_tx_exists << "ms"
<< ENDL
<< "time_add_block1: " << time_add_block1 << "ms"
<< ENDL
<< "time_add_transaction: " << time_add_transaction << "ms"
Expand Down
1 change: 1 addition & 0 deletions src/cryptonote_core/blockchain_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class BlockchainDB

protected:

mutable uint64_t time_tx_exists = 0;
uint64_t time_commit1 = 0;


Expand Down

0 comments on commit 6485dac

Please sign in to comment.