From fbdde8f0e67a1a2dc6a9ed9c9bf31fbba4b0b13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 11 Jul 2016 16:17:30 +0200 Subject: [PATCH] More benchmarks --- evmbin/bench.sh | 24 ++++++++++++++++++++++++ evmbin/benches/mod.rs | 26 +++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 evmbin/bench.sh diff --git a/evmbin/bench.sh b/evmbin/bench.sh new file mode 100755 index 000000000..a7d5557cb --- /dev/null +++ b/evmbin/bench.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -x +set -e + +cargo build --release + +# LOOP TEST +CODE1=606060405260005b620f42408112156019575b6001016007565b600081905550600680602b6000396000f3606060405200 +ethvm --code $CODE1 +echo "^^^^ ethvm" +./target/release/evm stats --code $CODE1 --gas 4402000 +echo "^^^^ usize" +./target/release/evm stats --code $CODE1 +echo "^^^^ U256" + +# RNG TEST +CODE2=6060604052600360056007600b60005b620f4240811215607f5767ffe7649d5eca84179490940267f47ed85c4b9a6379019367f8e5dd9a5c994bba9390930267f91d87e4b8b74e55019267ff97f6f3b29cda529290920267f393ada8dd75c938019167fe8d437c45bb3735830267f47d9a7b5428ffec019150600101600f565b838518831882186000555050505050600680609a6000396000f3606060405200 +ethvm --code $CODE2 +echo "^^^^ ethvm" +./target/release/evm stats --code $CODE2 --gas 143020115 +echo "^^^^ usize" +./target/release/evm stats --code $CODE2 +echo "^^^^ U256" diff --git a/evmbin/benches/mod.rs b/evmbin/benches/mod.rs index 3013a170a..3013dca54 100644 --- a/evmbin/benches/mod.rs +++ b/evmbin/benches/mod.rs @@ -47,7 +47,31 @@ fn simple_loop_u256(b: &mut Bencher) { fn simple_loop(gas: U256, b: &mut Bencher) { let code = black_box( - "606060405260005b620f42408112156019575b6001016007565b600081905550600680602b6000396000f3606060405200".from_hex().unwrap() + "606060405260005b620042408112156019575b6001016007565b600081905550600680602b6000396000f3606060405200".from_hex().unwrap() + ); + + b.iter(|| { + let mut params = ActionParams::default(); + params.gas = gas; + params.code = Some(code.clone()); + + run_vm(params) + }); +} + +#[bench] +fn rng_usize(b: &mut Bencher) { + rng(U256::from(::std::usize::MAX), b) +} + +#[bench] +fn rng_u256(b: &mut Bencher) { + rng(!U256::zero(), b) +} + +fn rng(gas: U256, b: &mut Bencher) { + let code = black_box( + "6060604052600360056007600b60005b62004240811215607f5767ffe7649d5eca84179490940267f47ed85c4b9a6379019367f8e5dd9a5c994bba9390930267f91d87e4b8b74e55019267ff97f6f3b29cda529290920267f393ada8dd75c938019167fe8d437c45bb3735830267f47d9a7b5428ffec019150600101600f565b838518831882186000555050505050600680609a6000396000f3606060405200".from_hex().unwrap() ); b.iter(|| {