Skip to content

Instantly share code, notes, and snippets.

@holiman
Last active August 19, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holiman/053790846eaac8c1ac43c680f38979d3 to your computer and use it in GitHub Desktop.
Save holiman/053790846eaac8c1ac43c680f38979d3 to your computer and use it in GitHub Desktop.
Raw values

Raw benchmark-values, on an Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz

[~/go/src/github.com/ethereum/go-ethereum/core/vm]
#go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcrecover/-Gas=3000-8         	   50000	    171600 ns/op
BenchmarkPrecompiledSha256/128-Gas=108-8          	10000000	       675 ns/op
BenchmarkPrecompiledRipeMD/128-Gas=1080-8         	 3000000	      2336 ns/op
BenchmarkPrecompiledIdentity/128-Gas=27-8         	500000000	        18.8 ns/op
BenchmarkPrecompiledModExp/eip_example1-Gas=2611-8         	   50000	    140894 ns/op
BenchmarkPrecompiledModExp/eip_example2-Gas=2611-8         	 1000000	      8229 ns/op
BenchmarkPrecompiledModExp/nagydani-1-square-Gas=40-8      	 2000000	      3032 ns/op
BenchmarkPrecompiledModExp/nagydani-1-qube-Gas=40-8        	 2000000	      3863 ns/op
BenchmarkPrecompiledModExp/nagydani-1-pow0x10001-Gas=655-8 	  500000	     16787 ns/op
BenchmarkPrecompiledModExp/nagydani-2-square-Gas=133-8     	 2000000	      4851 ns/op
BenchmarkPrecompiledModExp/nagydani-2-qube-Gas=133-8       	 1000000	      7024 ns/op
BenchmarkPrecompiledModExp/nagydani-2-pow0x10001-Gas=2129-8         	  200000	     35921 ns/op
BenchmarkPrecompiledModExp/nagydani-3-square-Gas=378-8              	 1000000	      8929 ns/op
BenchmarkPrecompiledModExp/nagydani-3-qube-Gas=378-8                	  500000	     14808 ns/op
BenchmarkPrecompiledModExp/nagydani-3-pow0x10001-Gas=6062-8         	  100000	     89075 ns/op
BenchmarkPrecompiledModExp/nagydani-4-square-Gas=1116-8             	  300000	     21403 ns/op
BenchmarkPrecompiledModExp/nagydani-4-qube-Gas=1116-8               	  200000	     42058 ns/op
BenchmarkPrecompiledModExp/nagydani-4-pow0x10001-Gas=17858-8        	   30000	    264793 ns/op
BenchmarkPrecompiledModExp/nagydani-5-square-Gas=3573-8             	  200000	     55296 ns/op
BenchmarkPrecompiledModExp/nagydani-5-qube-Gas=3573-8               	  100000	    114431 ns/op
BenchmarkPrecompiledModExp/nagydani-5-pow0x10001-Gas=57180-8        	   10000	    787085 ns/op
BenchmarkPrecompiledBn256Add/chfast1-Gas=500-8                      	  100000	     71559 ns/op
BenchmarkPrecompiledBn256Add/chfast2-Gas=500-8                      	  100000	     76264 ns/op
BenchmarkPrecompiledBn256Add/cdetrio1-Gas=500-8                     	 5000000	      1814 ns/op
BenchmarkPrecompiledBn256Add/cdetrio2-Gas=500-8                     	 5000000	      1818 ns/op
BenchmarkPrecompiledBn256Add/cdetrio3-Gas=500-8                     	 5000000	      1814 ns/op
BenchmarkPrecompiledBn256Add/cdetrio4-Gas=500-8                     	 5000000	      1844 ns/op
BenchmarkPrecompiledBn256Add/cdetrio5-Gas=500-8                     	 5000000	      1779 ns/op
BenchmarkPrecompiledBn256Add/cdetrio6-Gas=500-8                     	 5000000	      1917 ns/op
BenchmarkPrecompiledBn256Add/cdetrio7-Gas=500-8                     	 3000000	      1954 ns/op
BenchmarkPrecompiledBn256Add/cdetrio8-Gas=500-8                     	 5000000	      1982 ns/op
BenchmarkPrecompiledBn256Add/cdetrio9-Gas=500-8                     	 5000000	      1955 ns/op
BenchmarkPrecompiledBn256Add/cdetrio10-Gas=500-8                    	 5000000	      1945 ns/op
BenchmarkPrecompiledBn256Add/cdetrio11-Gas=500-8                    	 1000000	      8758 ns/op
BenchmarkPrecompiledBn256Add/cdetrio12-Gas=500-8                    	 1000000	      8912 ns/op
BenchmarkPrecompiledBn256Add/cdetrio13-Gas=500-8                    	  100000	     71075 ns/op
BenchmarkPrecompiledBn256Add/cdetrio14-Gas=500-8                    	 1000000	      8824 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast1-Gas=2000-8               	   10000	    715908 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast2-Gas=2000-8               	    3000	   2771988 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast3-Gas=2000-8               	    3000	   2782463 ns/op
BenchmarkPrecompiledBn256Pairing/jeff1-Gas=260000-8                 	     300	  26119632 ns/op
BenchmarkPrecompiledBn256Pairing/jeff2-Gas=260000-8                 	     300	  26363552 ns/op
BenchmarkPrecompiledBn256Pairing/jeff3-Gas=260000-8                 	     300	  26223865 ns/op
BenchmarkPrecompiledBn256Pairing/jeff4-Gas=340000-8                 	     200	  33361630 ns/op
BenchmarkPrecompiledBn256Pairing/jeff5-Gas=340000-8                 	     200	  33580489 ns/op
BenchmarkPrecompiledBn256Pairing/jeff6-Gas=260000-8                 	     300	  26025699 ns/op
BenchmarkPrecompiledBn256Pairing/empty_data-Gas=100000-8            	    5000	   1775018 ns/op
BenchmarkPrecompiledBn256Pairing/one_point-Gas=180000-8             	     500	  18469799 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_2-Gas=260000-8     	     500	  15477827 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_3-Gas=260000-8     	     300	  25841751 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_4-Gas=260000-8     	     300	  25606363 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_1-Gas=900000-8     	     100	  69291092 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_2-Gas=900000-8     	     100	  82093662 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_3-Gas=260000-8     	     300	  25540923 ns/op
PASS
ok  	github.com/ethereum/go-ethereum/core/vm	521.513s

The values above, but translated into a table

Name                                         Gascost         Time (ns)       MGas/S    Gasprice for 10MGas/S  Gas/Ideal percent
-----------------------------------------  ---------  ----------------  -----------  -----------------------  -------------------
PrecompiledEcrecover/                           3000  171600              17.4825                   1716      174.8 %
PrecompiledSha256/128                            108     675             160                           6.75   1600.0 %
PrecompiledRipeMD/128                           1080    2336             462.329                      23.36   4623.3 %
PrecompiledIdentity/128                           27      18.8          1436.17                        0.188  14361.7 %
PrecompiledModExp/eip_example1                  2611  140894              18.5317                   1408.94   185.3 %
PrecompiledModExp/eip_example2                  2611    8229             317.293                      82.29   3172.9 %
PrecompiledModExp/nagydani-1-square               40    3032              13.1926                     30.32   131.9 %
PrecompiledModExp/nagydani-1-qube                 40    3863              10.3546                     38.63   103.5 %
PrecompiledModExp/nagydani-1-pow0x10001          655   16787              39.0183                    167.87   390.2 %
PrecompiledModExp/nagydani-2-square              133    4851              27.417                      48.51   274.2 %
PrecompiledModExp/nagydani-2-qube                133    7024              18.9351                     70.24   189.4 %
PrecompiledModExp/nagydani-2-pow0x10001         2129   35921              59.269                     359.21   592.7 %
PrecompiledModExp/nagydani-3-square              378    8929              42.334                      89.29   423.3 %
PrecompiledModExp/nagydani-3-qube                378   14808              25.5267                    148.08   255.3 %
PrecompiledModExp/nagydani-3-pow0x10001         6062   89075              68.055                     890.75   680.6 %
PrecompiledModExp/nagydani-4-square             1116   21403              52.1422                    214.03   521.4 %
PrecompiledModExp/nagydani-4-qube               1116   42058              26.5348                    420.58   265.3 %
PrecompiledModExp/nagydani-4-pow0x10001        17858  264793              67.4414                   2647.93   674.4 %
PrecompiledModExp/nagydani-5-square             3573   55296              64.6159                    552.96   646.2 %
PrecompiledModExp/nagydani-5-qube               3573  114431              31.2241                   1144.31   312.2 %
PrecompiledModExp/nagydani-5-pow0x10001        57180  787085              72.6478                   7870.85   726.5 %
PrecompiledBn256Add/chfast1                      500   71559               6.98724                   715.59   69.9 %
PrecompiledBn256Add/chfast2                      500   76264               6.55617                   762.64   65.6 %
PrecompiledBn256Add/cdetrio1                     500    1814             275.634                      18.14   2756.3 %
PrecompiledBn256Add/cdetrio2                     500    1818             275.028                      18.18   2750.3 %
PrecompiledBn256Add/cdetrio3                     500    1814             275.634                      18.14   2756.3 %
PrecompiledBn256Add/cdetrio4                     500    1844             271.15                       18.44   2711.5 %
PrecompiledBn256Add/cdetrio5                     500    1779             281.057                      17.79   2810.6 %
PrecompiledBn256Add/cdetrio6                     500    1917             260.824                      19.17   2608.2 %
PrecompiledBn256Add/cdetrio7                     500    1954             255.885                      19.54   2558.9 %
PrecompiledBn256Add/cdetrio8                     500    1982             252.27                       19.82   2522.7 %
PrecompiledBn256Add/cdetrio9                     500    1955             255.754                      19.55   2557.5 %
PrecompiledBn256Add/cdetrio10                    500    1945             257.069                      19.45   2570.7 %
PrecompiledBn256Add/cdetrio11                    500    8758              57.0907                     87.58   570.9 %
PrecompiledBn256Add/cdetrio12                    500    8912              56.1041                     89.12   561.0 %
PrecompiledBn256Add/cdetrio13                    500   71075               7.03482                   710.75   70.3 %
PrecompiledBn256Add/cdetrio14                    500    8824              56.6636                     88.24   566.6 %
PrecompiledBn256ScalarMul/chfast1               2000  715908               2.79366                  7159.08   27.9 %
PrecompiledBn256ScalarMul/chfast2               2000       2.77199e+06     0.721504                27719.9    7.2 %
PrecompiledBn256ScalarMul/chfast3               2000       2.78246e+06     0.718788                27824.6    7.2 %
PrecompiledBn256Pairing/jeff1                 260000       2.61196e+07     9.9542                 261196      99.5 %
PrecompiledBn256Pairing/jeff2                 260000       2.63636e+07     9.8621                 263636      98.6 %
PrecompiledBn256Pairing/jeff3                 260000       2.62239e+07     9.91463                262239      99.1 %
PrecompiledBn256Pairing/jeff4                 340000       3.33616e+07    10.1913                 333616      101.9 %
PrecompiledBn256Pairing/jeff5                 340000       3.35805e+07    10.1249                 335805      101.2 %
PrecompiledBn256Pairing/jeff6                 260000       2.60257e+07     9.99013                260257      99.9 %
PrecompiledBn256Pairing/empty_data            100000       1.77502e+06    56.3375                  17750.2    563.4 %
PrecompiledBn256Pairing/one_point             180000       1.84698e+07     9.74564                184698      97.5 %
PrecompiledBn256Pairing/two_point_match_2     260000       1.54778e+07    16.7982                 154778      168.0 %
PrecompiledBn256Pairing/two_point_match_3     260000       2.58418e+07    10.0612                 258418      100.6 %
PrecompiledBn256Pairing/two_point_match_4     260000       2.56064e+07    10.1537                 256064      101.5 %
PrecompiledBn256Pairing/ten_point_match_1     900000       6.92911e+07    12.9887                 692911      129.9 %
PrecompiledBn256Pairing/ten_point_match_2     900000       8.20937e+07    10.9631                 820937      109.6 %
PrecompiledBn256Pairing/ten_point_match_3     260000       2.55409e+07    10.1797                 255409      101.8 %

Same again, but I have only kept the worst-case benchmarks for each precompile - the test vectors which yield the lowest MGas/s values.

Name                                         Gascost         Time (ns)       MGas/S    Gasprice for 10MGas/S  Gas/Ideal percent
-----------------------------------------  ---------  ----------------  -----------  -----------------------  -------------------
PrecompiledEcrecover/                           3000  171600              17.4825                   1716      174.8 %
PrecompiledSha256/128                            108     675             160                           6.75   1600.0 %
PrecompiledRipeMD/128                           1080    2336             462.329                      23.36   4623.3 %
PrecompiledIdentity/128                           27      18.8          1436.17                        0.188  14361.7 %
PrecompiledModExp/nagydani-1-qube                 40    3863              10.3546                     38.63   103.5 %
PrecompiledBn256Add/chfast2                      500   76264               6.55617                   762.64   65.6 %
PrecompiledBn256ScalarMul/chfast3               2000       2.78246e+06     0.718788                27824.6    7.2 %
PrecompiledBn256Pairing/one_point             180000       1.84698e+07     9.74564                184698      97.5 %
PrecompiledBn256Pairing/two_point_match_3     260000       2.58418e+07    10.0612                 258418      100.6 %
PrecompiledBn256Pairing/ten_point_match_3     260000       2.55409e+07    10.1797                 255409      101.8 %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment