aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorwarptangent <warptangent@inbox.com>2015-02-11 15:55:53 -0800
committerwarptangent <warptangent@inbox.com>2015-02-23 00:33:37 -0800
commit3676ac5841b1e433830323b3c51bf78e96947054 (patch)
treec484b4e00231247a0c0e34f270a2da085e4a1ad9 /src/cryptonote_core
parentMove LMDB storage to subfolder (diff)
downloadmonero-3676ac5841b1e433830323b3c51bf78e96947054.tar.xz
Add profiling to block and tx processing
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain_db.cpp38
-rw-r--r--src/cryptonote_core/blockchain_db.h10
2 files changed, 48 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain_db.cpp b/src/cryptonote_core/blockchain_db.cpp
index 0ee10bd4d..615b08814 100644
--- a/src/cryptonote_core/blockchain_db.cpp
+++ b/src/cryptonote_core/blockchain_db.cpp
@@ -28,6 +28,7 @@
#include "cryptonote_core/blockchain_db.h"
#include "cryptonote_format_utils.h"
+#include "profile_tools.h"
using epee::string_tools::pod_to_hex;
@@ -73,18 +74,29 @@ uint64_t BlockchainDB::add_block( const block& blk
, const std::vector<transaction>& txs
)
{
+ TIME_MEASURE_START(time1);
crypto::hash blk_hash = get_block_hash(blk);
+ TIME_MEASURE_FINISH(time1);
+ time_blk_hash += time1;
// call out to subclass implementation to add the block & metadata
+ time1 = epee::misc_utils::get_tick_count();
add_block(blk, block_size, cumulative_difficulty, coins_generated);
+ TIME_MEASURE_FINISH(time1);
+ time_add_block1 += time1;
// call out to add the transactions
+ time1 = epee::misc_utils::get_tick_count();
add_transaction(blk_hash, blk.miner_tx);
for (const transaction& tx : txs)
{
add_transaction(blk_hash, tx);
}
+ TIME_MEASURE_FINISH(time1);
+ time_add_transaction += time1;
+
+ ++num_calls;
return height();
}
@@ -119,4 +131,30 @@ void BlockchainDB::remove_transaction(const crypto::hash& tx_hash)
remove_transaction_data(tx_hash, tx);
}
+void BlockchainDB::reset_stats()
+{
+ num_calls = 0;
+ time_blk_hash = 0;
+ time_add_block1 = 0;
+ time_add_transaction = 0;
+}
+
+void BlockchainDB::show_stats()
+{
+ LOG_PRINT_L1(ENDL
+ << "*********************************"
+ << ENDL
+ << "num_calls: " << num_calls
+ << ENDL
+ << "time_blk_hash: " << time_blk_hash << "ms"
+ << ENDL
+ << "time_add_block1: " << time_add_block1 << "ms"
+ << ENDL
+ << "time_add_transaction: " << time_add_transaction << "ms"
+ << ENDL
+ << "*********************************"
+ << ENDL
+ );
+}
+
} // namespace cryptonote
diff --git a/src/cryptonote_core/blockchain_db.h b/src/cryptonote_core/blockchain_db.h
index db56c7c07..531de04bd 100644
--- a/src/cryptonote_core/blockchain_db.h
+++ b/src/cryptonote_core/blockchain_db.h
@@ -301,12 +301,22 @@ private:
// helper function to remove transaction from blockchain
void remove_transaction(const crypto::hash& tx_hash);
+ uint64_t num_calls = 0;
+ uint64_t time_blk_hash = 0;
+ uint64_t time_add_block1 = 0;
+ uint64_t time_add_transaction = 0;
+
public:
// virtual dtor
virtual ~BlockchainDB() { };
+ // reset profiling stats
+ void reset_stats();
+
+ // show profiling stats
+ void show_stats();
// open the db at location <filename>, or create it if there isn't one.
virtual void open(const std::string& filename) = 0;