From 261c1e2a3ff8424523f738c6eb43a322fd5499f9 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 09:00:51 +0100 Subject: [PATCH 1/3] performance test --- vm.cpp | 28 ++++++++++++++++++++++++++ vmPerformanceTestFiller.json | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 vmPerformanceTestFiller.json diff --git a/vm.cpp b/vm.cpp index f15dc048a..af946777f 100644 --- a/vm.cpp +++ b/vm.cpp @@ -32,6 +32,8 @@ using namespace dev; using namespace dev::eth; using namespace dev::test; +using Millisecs = chrono::duration; + FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {} @@ -513,13 +515,39 @@ BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) dev::test::executeTests("vmSystemOperationsTest", "/VMTests", dev::test::doVMTests); } +BOOST_AUTO_TEST_CASE(vmPerformanceTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--performance") + { + chrono::steady_clock::time_point start = chrono::steady_clock::now(); + + dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); + + chrono::steady_clock::time_point end = chrono::steady_clock::now(); + Millisecs duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} + BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) { string arg = boost::unit_test::framework::master_test_suite().argv[i]; if (arg == "--inputlimits") + { + chrono::steady_clock::time_point start = chrono::steady_clock::now(); + dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); + + chrono::steady_clock::time_point end = chrono::steady_clock::now(); + Millisecs duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } } } diff --git a/vmPerformanceTestFiller.json b/vmPerformanceTestFiller.json new file mode 100644 index 000000000..7979bfbdb --- /dev/null +++ b/vmPerformanceTestFiller.json @@ -0,0 +1,38 @@ +{ + "ackermann33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "contract PerformanceTester {", + "//" : " function ackermann(uint m, uint n) returns (uint) {", + "//" : " if (m == 0)", + "//" : " return n + 1;", + "//" : " if (n == 0)", + "//" : " return ackermann(m - 1, 1);", + "//" : " return ackermann(m - 1, ackermann(m, n - 1));", + "//" : " }", + "//" : "}", + "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003", + "gasPrice" : "100000000000000", + "gas" : "100000000000" + } + } +} From 10952220e33996a7fe6ec48a3570e9b777e6bf5e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 09:07:07 +0100 Subject: [PATCH 2/3] style fix --- vmPerformanceTestFiller.json | 64 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/vmPerformanceTestFiller.json b/vmPerformanceTestFiller.json index 7979bfbdb..7cfe659d5 100644 --- a/vmPerformanceTestFiller.json +++ b/vmPerformanceTestFiller.json @@ -1,38 +1,38 @@ { "ackermann33": { - "env" : { - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", - "currentNumber" : "0", - "currentGasLimit" : "100000000000", - "currentDifficulty" : "256", - "currentTimestamp" : "1", - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" - }, - "pre" : { - "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", - "nonce" : "0", - "//" : "contract PerformanceTester {", - "//" : " function ackermann(uint m, uint n) returns (uint) {", - "//" : " if (m == 0)", - "//" : " return n + 1;", - "//" : " if (n == 0)", - "//" : " return ackermann(m - 1, 1);", - "//" : " return ackermann(m - 1, ackermann(m, n - 1));", - "//" : " }", - "//" : "}", - "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", - "storage": {} - } - }, + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "contract PerformanceTester {", + "//" : " function ackermann(uint m, uint n) returns (uint) {", + "//" : " if (m == 0)", + "//" : " return n + 1;", + "//" : " if (n == 0)", + "//" : " return ackermann(m - 1, 1);", + "//" : " return ackermann(m - 1, ackermann(m, n - 1));", + "//" : " }", + "//" : "}", + "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", + "storage": {} + } + }, "exec" : { - "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003", - "gasPrice" : "100000000000000", + "gasPrice" : "100000000000000", "gas" : "100000000000" - } - } + } + } } From cdb7565707ccfc960a30fd403570f21f15d08253 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 10:27:38 +0100 Subject: [PATCH 3/3] use auto for steady clock and chrono::milliseconds --- vm.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/vm.cpp b/vm.cpp index af946777f..faab48129 100644 --- a/vm.cpp +++ b/vm.cpp @@ -32,8 +32,6 @@ using namespace dev; using namespace dev::eth; using namespace dev::test; -using Millisecs = chrono::duration; - FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {} @@ -522,12 +520,12 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest) string arg = boost::unit_test::framework::master_test_suite().argv[i]; if (arg == "--performance") { - chrono::steady_clock::time_point start = chrono::steady_clock::now(); + auto start = chrono::steady_clock::now(); dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); - chrono::steady_clock::time_point end = chrono::steady_clock::now(); - Millisecs duration(chrono::duration_cast(end - start)); + auto end = chrono::steady_clock::now(); + chrono::milliseconds duration(chrono::duration_cast(end - start)); cnote << "test duration: " << duration.count() << " milliseconds.\n"; } } @@ -540,12 +538,12 @@ BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) string arg = boost::unit_test::framework::master_test_suite().argv[i]; if (arg == "--inputlimits") { - chrono::steady_clock::time_point start = chrono::steady_clock::now(); + auto start = chrono::steady_clock::now(); dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); - chrono::steady_clock::time_point end = chrono::steady_clock::now(); - Millisecs duration(chrono::duration_cast(end - start)); + auto end = chrono::steady_clock::now(); + chrono::milliseconds duration(chrono::duration_cast(end - start)); cnote << "test duration: " << duration.count() << " milliseconds.\n"; } }