diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 6b4753e9919..fd11b129155 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -87,19 +87,38 @@ using namespace eosio::chain; api_handle->call_name(vs.at(0).as(), vs.at(1).as(), result_handler); struct txn_test_gen_plugin_impl { - static void push_next_transaction(const std::shared_ptr>& trxs, size_t index, const std::function& next ) { + + uint64_t _total_us = 0; + uint64_t _txcount = 0; + + int _remain = 0; + + void push_next_transaction(const std::shared_ptr>& trxs, size_t index, const std::function& next ) { chain_plugin& cp = app().get_plugin(); - cp.accept_transaction( packed_transaction(trxs->at(index)), [=](const fc::static_variant& result){ - if (result.contains()) { - next(result.get()); - } else { - if (index + 1 < trxs->size()) { - push_next_transaction(trxs, index + 1, next); + + const int overlap = 20; + int end = std::min(index + overlap, trxs->size()); + _remain = end - index; + for (int i = index; i < end; ++i) { + cp.accept_transaction( packed_transaction(trxs->at(i)), [=](const fc::static_variant& result){ + if (result.contains()) { + next(result.get()); } else { - next(nullptr); + if (result.contains() && result.get()->receipt) { + _total_us += result.get()->receipt->cpu_usage_us; + ++_txcount; + } + --_remain; + if (_remain == 0 ) { + if (end < trxs->size()) { + push_next_transaction(trxs, index + overlap, next); + } else { + next(nullptr); + } + } } - } - }); + }); + } } void push_transactions( std::vector&& trxs, const std::function& next ) { @@ -295,13 +314,11 @@ struct txn_test_gen_plugin_impl { try { controller& cc = app().get_plugin().chain(); auto chainid = app().get_plugin().get_chain_id(); - auto abi_serializer_max_time = app().get_plugin().get_abi_serializer_max_time(); - fc::crypto::private_key a_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'a'))); - fc::crypto::private_key b_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'b'))); + static fc::crypto::private_key a_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'a'))); + static fc::crypto::private_key b_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'b'))); static uint64_t nonce = static_cast(fc::time_point::now().sec_since_epoch()) << 32; - abi_serializer eosio_serializer(cc.db().find(config::system_account_name)->get_abi(), abi_serializer_max_time); uint32_t reference_block_num = cc.last_irreversible_block_num(); if (txn_reference_block_lag >= 0) { @@ -351,6 +368,11 @@ struct txn_test_gen_plugin_impl { timer.cancel(); running = false; ilog("Stopping transaction generation test"); + + if (_txcount) { + ilog("${d} transactions executed, ${t}us / transaction", ("d", _txcount)("t", _total_us / (double)_txcount)); + _txcount = _total_us = 0; + } } boost::asio::high_resolution_timer timer{app().get_io_service()};