aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-06 19:32:32 +0800
committerchriseth <chris@ethereum.org>2018-12-06 20:07:14 +0800
commit61241763749f4f27cd7abc1db4efd10a3a36b350 (patch)
tree93f01a5b671e3b0fff340549ccb7a7c5096c6346 /test
parent7f39c3e52226e133d4224a7afb763a3c5b4c525e (diff)
downloaddexon-solidity-61241763749f4f27cd7abc1db4efd10a3a36b350.tar.gz
dexon-solidity-61241763749f4f27cd7abc1db4efd10a3a36b350.tar.zst
dexon-solidity-61241763749f4f27cd7abc1db4efd10a3a36b350.zip
Gas tests for the binary search dispatch routine.
Diffstat (limited to 'test')
-rw-r--r--test/cmdlineTests/gas_test_dispatch.sol43
-rw-r--r--test/cmdlineTests/gas_test_dispatch.sol.args1
-rw-r--r--test/cmdlineTests/gas_test_dispatch.sol.stdout53
-rw-r--r--test/cmdlineTests/gas_test_dispatch_optimize.sol43
-rw-r--r--test/cmdlineTests/gas_test_dispatch_optimize.sol.args1
-rw-r--r--test/cmdlineTests/gas_test_dispatch_optimize.sol.stdout53
6 files changed, 194 insertions, 0 deletions
diff --git a/test/cmdlineTests/gas_test_dispatch.sol b/test/cmdlineTests/gas_test_dispatch.sol
new file mode 100644
index 00000000..a5ca9e7d
--- /dev/null
+++ b/test/cmdlineTests/gas_test_dispatch.sol
@@ -0,0 +1,43 @@
+pragma solidity >=0.0;
+
+contract Large {
+ uint public a;
+ uint[] public b;
+ function f1(uint x) public returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function f2(uint x) public returns (uint) { b[uint8(msg.data[1])] = x; }
+ function f3(uint x) public returns (uint) { b[uint8(msg.data[2])] = x; }
+ function f4(uint x) public returns (uint) { b[uint8(msg.data[3])] = x; }
+ function f5(uint x) public returns (uint) { b[uint8(msg.data[4])] = x; }
+ function f6(uint x) public returns (uint) { b[uint8(msg.data[5])] = x; }
+ function f7(uint x) public returns (uint) { b[uint8(msg.data[6])] = x; }
+ function f8(uint x) public returns (uint) { b[uint8(msg.data[7])] = x; }
+ function f9(uint x) public returns (uint) { b[uint8(msg.data[8])] = x; }
+ function f0(uint x) public pure returns (uint) { require(x > 10); }
+ function g1(uint x) public payable returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function g2(uint x) public payable returns (uint) { b[uint8(msg.data[1])] = x; }
+ function g3(uint x) public payable returns (uint) { b[uint8(msg.data[2])] = x; }
+ function g4(uint x) public payable returns (uint) { b[uint8(msg.data[3])] = x; }
+ function g5(uint x) public payable returns (uint) { b[uint8(msg.data[4])] = x; }
+ function g6(uint x) public payable returns (uint) { b[uint8(msg.data[5])] = x; }
+ function g7(uint x) public payable returns (uint) { b[uint8(msg.data[6])] = x; }
+ function g8(uint x) public payable returns (uint) { b[uint8(msg.data[7])] = x; }
+ function g9(uint x) public payable returns (uint) { b[uint8(msg.data[8])] = x; }
+ function g0(uint x) public payable returns (uint) { require(x > 10); }
+}
+contract Medium {
+ uint public a;
+ uint[] public b;
+ function f1(uint x) public returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function f2(uint x) public returns (uint) { b[uint8(msg.data[1])] = x; }
+ function f3(uint x) public returns (uint) { b[uint8(msg.data[2])] = x; }
+ function g7(uint x) public payable returns (uint) { b[uint8(msg.data[6])] = x; }
+ function g8(uint x) public payable returns (uint) { b[uint8(msg.data[7])] = x; }
+ function g9(uint x) public payable returns (uint) { b[uint8(msg.data[8])] = x; }
+ function g0(uint x) public payable returns (uint) { require(x > 10); }
+}
+contract Small {
+ uint public a;
+ uint[] public b;
+ function f1(uint x) public returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function () external payable {}
+}
diff --git a/test/cmdlineTests/gas_test_dispatch.sol.args b/test/cmdlineTests/gas_test_dispatch.sol.args
new file mode 100644
index 00000000..3684987e
--- /dev/null
+++ b/test/cmdlineTests/gas_test_dispatch.sol.args
@@ -0,0 +1 @@
+--gas
diff --git a/test/cmdlineTests/gas_test_dispatch.sol.stdout b/test/cmdlineTests/gas_test_dispatch.sol.stdout
new file mode 100644
index 00000000..117affad
--- /dev/null
+++ b/test/cmdlineTests/gas_test_dispatch.sol.stdout
@@ -0,0 +1,53 @@
+
+======= gas_test_dispatch.sol:Large =======
+Gas estimation:
+construction:
+ 1034 + 998400 = 999434
+external:
+ a(): 456
+ b(uint256): 857
+ f0(uint256): 438
+ f1(uint256): 40781
+ f2(uint256): 20722
+ f3(uint256): 20810
+ f4(uint256): 20788
+ f5(uint256): 20766
+ f6(uint256): 20789
+ f7(uint256): 20701
+ f8(uint256): 20701
+ f9(uint256): 20723
+ g0(uint256): 324
+ g1(uint256): 40736
+ g2(uint256): 20699
+ g3(uint256): 20787
+ g4(uint256): 20765
+ g5(uint256): 20721
+ g6(uint256): 20744
+ g7(uint256): 20743
+ g8(uint256): 20721
+ g9(uint256): 20678
+
+======= gas_test_dispatch.sol:Medium =======
+Gas estimation:
+construction:
+ 411 + 376600 = 377011
+external:
+ a(): 433
+ b(uint256): 857
+ f1(uint256): 40692
+ f2(uint256): 20722
+ f3(uint256): 20766
+ g0(uint256): 324
+ g7(uint256): 20721
+ g8(uint256): 20699
+ g9(uint256): 20655
+
+======= gas_test_dispatch.sol:Small =======
+Gas estimation:
+construction:
+ 153 + 107800 = 107953
+external:
+ fallback: 123
+ a(): 388
+ b(uint256): 813
+ f1(uint256): 40692
diff --git a/test/cmdlineTests/gas_test_dispatch_optimize.sol b/test/cmdlineTests/gas_test_dispatch_optimize.sol
new file mode 100644
index 00000000..a5ca9e7d
--- /dev/null
+++ b/test/cmdlineTests/gas_test_dispatch_optimize.sol
@@ -0,0 +1,43 @@
+pragma solidity >=0.0;
+
+contract Large {
+ uint public a;
+ uint[] public b;
+ function f1(uint x) public returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function f2(uint x) public returns (uint) { b[uint8(msg.data[1])] = x; }
+ function f3(uint x) public returns (uint) { b[uint8(msg.data[2])] = x; }
+ function f4(uint x) public returns (uint) { b[uint8(msg.data[3])] = x; }
+ function f5(uint x) public returns (uint) { b[uint8(msg.data[4])] = x; }
+ function f6(uint x) public returns (uint) { b[uint8(msg.data[5])] = x; }
+ function f7(uint x) public returns (uint) { b[uint8(msg.data[6])] = x; }
+ function f8(uint x) public returns (uint) { b[uint8(msg.data[7])] = x; }
+ function f9(uint x) public returns (uint) { b[uint8(msg.data[8])] = x; }
+ function f0(uint x) public pure returns (uint) { require(x > 10); }
+ function g1(uint x) public payable returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function g2(uint x) public payable returns (uint) { b[uint8(msg.data[1])] = x; }
+ function g3(uint x) public payable returns (uint) { b[uint8(msg.data[2])] = x; }
+ function g4(uint x) public payable returns (uint) { b[uint8(msg.data[3])] = x; }
+ function g5(uint x) public payable returns (uint) { b[uint8(msg.data[4])] = x; }
+ function g6(uint x) public payable returns (uint) { b[uint8(msg.data[5])] = x; }
+ function g7(uint x) public payable returns (uint) { b[uint8(msg.data[6])] = x; }
+ function g8(uint x) public payable returns (uint) { b[uint8(msg.data[7])] = x; }
+ function g9(uint x) public payable returns (uint) { b[uint8(msg.data[8])] = x; }
+ function g0(uint x) public payable returns (uint) { require(x > 10); }
+}
+contract Medium {
+ uint public a;
+ uint[] public b;
+ function f1(uint x) public returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function f2(uint x) public returns (uint) { b[uint8(msg.data[1])] = x; }
+ function f3(uint x) public returns (uint) { b[uint8(msg.data[2])] = x; }
+ function g7(uint x) public payable returns (uint) { b[uint8(msg.data[6])] = x; }
+ function g8(uint x) public payable returns (uint) { b[uint8(msg.data[7])] = x; }
+ function g9(uint x) public payable returns (uint) { b[uint8(msg.data[8])] = x; }
+ function g0(uint x) public payable returns (uint) { require(x > 10); }
+}
+contract Small {
+ uint public a;
+ uint[] public b;
+ function f1(uint x) public returns (uint) { a = x; b[uint8(msg.data[0])] = x; }
+ function () external payable {}
+}
diff --git a/test/cmdlineTests/gas_test_dispatch_optimize.sol.args b/test/cmdlineTests/gas_test_dispatch_optimize.sol.args
new file mode 100644
index 00000000..814e0591
--- /dev/null
+++ b/test/cmdlineTests/gas_test_dispatch_optimize.sol.args
@@ -0,0 +1 @@
+--optimize --optimize-runs 2 --gas
diff --git a/test/cmdlineTests/gas_test_dispatch_optimize.sol.stdout b/test/cmdlineTests/gas_test_dispatch_optimize.sol.stdout
new file mode 100644
index 00000000..76fa086e
--- /dev/null
+++ b/test/cmdlineTests/gas_test_dispatch_optimize.sol.stdout
@@ -0,0 +1,53 @@
+
+======= gas_test_dispatch_optimize.sol:Large =======
+Gas estimation:
+construction:
+ 300 + 262000 = 262300
+external:
+ a(): 463
+ b(uint256): 1173
+ f0(uint256): 399
+ f1(uint256): 41164
+ f2(uint256): 21224
+ f3(uint256): 21312
+ f4(uint256): 21290
+ f5(uint256): 21268
+ f6(uint256): 21180
+ f7(uint256): 20960
+ f8(uint256): 21092
+ f9(uint256): 21114
+ g0(uint256): 639
+ g1(uint256): 40876
+ g2(uint256): 20958
+ g3(uint256): 21046
+ g4(uint256): 21024
+ g5(uint256): 21112
+ g6(uint256): 20892
+ g7(uint256): 21002
+ g8(uint256): 20980
+ g9(uint256): 20826
+
+======= gas_test_dispatch_optimize.sol:Medium =======
+Gas estimation:
+construction:
+ 190 + 143000 = 143190
+external:
+ a(): 463
+ b(uint256): 931
+ f1(uint256): 40944
+ f2(uint256): 20982
+ f3(uint256): 21026
+ g0(uint256): 397
+ g7(uint256): 20892
+ g8(uint256): 20870
+ g9(uint256): 20826
+
+======= gas_test_dispatch_optimize.sol:Small =======
+Gas estimation:
+construction:
+ 117 + 67400 = 67517
+external:
+ fallback: 183
+ a(): 441
+ b(uint256): 821
+ f1(uint256): 40878