diff options
author | Paweł Bylica <pawel.bylica@imapp.pl> | 2015-03-13 18:19:26 +0800 |
---|---|---|
committer | Paweł Bylica <chfast@gmail.com> | 2015-03-14 07:18:52 +0800 |
commit | 31db4fbde86ede91b3af9336d7632e4c700960d6 (patch) | |
tree | 9eed19c85fde75a779d2895137fc54b4c60a5f0a /vm.cpp | |
parent | f15e1ef250dc9c2c32a2857d36920369ac5e62ce (diff) | |
download | dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.tar dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.tar.gz dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.tar.bz2 dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.tar.lz dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.tar.xz dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.tar.zst dexon-solidity-31db4fbde86ede91b3af9336d7632e4c700960d6.zip |
Stats for testeth
Simple listener support added to testeth. Stats class implements the Listener interface and collects tests execution times. Try options: --stats or --stats=full.
Closes ethereum/cpp-ethereum#1285
Diffstat (limited to 'vm.cpp')
-rw-r--r-- | vm.cpp | 39 |
1 files changed, 9 insertions, 30 deletions
@@ -20,13 +20,12 @@ * vm test functions. */ -#include <chrono> - #include <boost/filesystem.hpp> #include <libethereum/Executive.h> #include <libevm/VMFactory.h> #include "vm.h" +#include "Stats.h" using namespace std; using namespace json_spirit; @@ -312,7 +311,8 @@ namespace dev { namespace test { void doVMTests(json_spirit::mValue& v, bool _fillin) { - Options::get(); // process command line options // TODO: We need to control the main() function + if (Options::get().stats) + Listener::registerListener(Stats::get()); for (auto& i: v.get_obj()) { @@ -340,12 +340,16 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) bytes output; u256 gas; bool vmExceptionOccured = false; - auto startTime = std::chrono::high_resolution_clock::now(); try { auto vm = eth::VMFactory::create(fev.gas); auto vmtrace = Options::get().vmtrace ? fev.simpleTrace() : OnOpFunc{}; - output = vm->go(fev, vmtrace).toBytes(); + auto outputRef = bytesConstRef{}; + { + Listener::ExecTimeGuard guard{i.first}; + outputRef = vm->go(fev, vmtrace); + } + output = outputRef.toBytes(); gas = vm->gas(); } catch (VMException const&) @@ -364,15 +368,6 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) BOOST_ERROR("Failed VM Test with Exception: " << _e.what()); } - auto endTime = std::chrono::high_resolution_clock::now(); - if (Options::get().showTimes) - { - auto testDuration = endTime - startTime; - cnote << "Execution time: " - << std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count() - << " ms"; - } - // delete null entries in storage for the sake of comparison for (auto &a: fev.addresses) @@ -513,29 +508,13 @@ BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) BOOST_AUTO_TEST_CASE(vmPerformanceTest) { if (test::Options::get().performance) - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast<chrono::milliseconds>(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } } BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) { if (test::Options::get().inputLimits) - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("vmInputLimits1", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast<chrono::milliseconds>(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } } BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) |