Skip to content

Instantly share code, notes, and snippets.

@timxor
Last active August 2, 2017 10:42
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 timxor/635e76216769cf67d7befe0918ddf176 to your computer and use it in GitHub Desktop.
Save timxor/635e76216769cf67d7befe0918ddf176 to your computer and use it in GitHub Desktop.
run geth benchmarks from scratch (on mac)

How to run some go-ethereum (geth) metropolis benchmarks

Clone repo and install dependency's:

git clone https://github.com/tcsiwula/go-ethereum.git

cd go-ethereum

go get -d ./...

go get github.com/ethereum/go-ethereum/common

go get golang.org/x/crypto/ripemd160

Checkout metropolis brnach

git checkout -b metropolis

git pull origin metropolis

Change directory

cd go-ethereum/core/vm

Precompiled Contract file

Contracts.go New contracts (line #53) for metropolis include: bigModexp, bn256Add, bn256ScalarMul and paring.

Benchmark test file

instructions_test.go

run some benchmarks

go test . -run - -bench BenchmarkPrecompile

on tims slow macbook (need new one)

=>pwd
/Users/timsiwula/Dropbox/Projects/go-ethereum/core/vm
=>go test -bench=.
BenchmarkPrecompiledEcdsa/-Gas=3000-8  	   10000	    172878 ns/op
BenchmarkPrecompiledSha256/128-Gas=108-8         	 2000000	       665 ns/op
BenchmarkPrecompiledRipeMD/128-Gas=1080-8        	 1000000	      2040 ns/op
BenchmarkPrecompiledIdentity/128-Gas=27-8        	100000000	        18.0 ns/op
BenchmarkPrecompiledModexp/eip_example1-Gas=4197376-8         	   50000	     35469 ns/op
BenchmarkPrecompiledModexp/eip_example2-Gas=4459488-8         	  200000	      8458 ns/op
BenchmarkPrecompiledBn256Add/chfast1-Gas=0-8                  	   30000	     49959 ns/op
BenchmarkPrecompiledBn256Add/chfast2-Gas=0-8                  	   30000	     50720 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast1-Gas=0-8            	    3000	    515170 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast2-Gas=0-8            	    1000	   2147972 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast3-Gas=0-8            	    1000	   1941908 ns/op
BenchmarkPrecompiledPairing/jeff1-Gas=160000-8                	     100	  20855539 ns/op
BenchmarkPrecompiledPairing/jeff2-Gas=160000-8                	     100	  22414865 ns/op
BenchmarkPrecompiledPairing/jeff3-Gas=160000-8                	     100	  20573412 ns/op
BenchmarkPrecompiledPairing/jeff4-Gas=220000-8                	      50	  25427069 ns/op
BenchmarkPrecompiledPairing/jeff5-Gas=220000-8                	      50	  26677504 ns/op
BenchmarkPrecompiledPairing/jeff6-Gas=160000-8                	     100	  21196777 ns/op
BenchmarkPrecompiledPairing/empty_data-Gas=40000-8            	100000000	        16.0 ns/op
BenchmarkPrecompiledPairing/one_point-Gas=100000-8            	     100	  14714009 ns/op
BenchmarkPrecompiledPairing/two_point_match_2-Gas=160000-8    	     100	  12536495 ns/op
BenchmarkPrecompiledPairing/two_point_match_3-Gas=160000-8    	     100	  20388733 ns/op
BenchmarkPrecompiledPairing/two_point_match_4-Gas=160000-8    	     100	  20516222 ns/op
BenchmarkPrecompiledPairing/ten_point_match_1-Gas=640000-8    	      30	  54420521 ns/op
BenchmarkPrecompiledPairing/ten_point_match_2-Gas=640000-8    	      20	  66125406 ns/op
BenchmarkPrecompiledPairing/ten_point_match_3-Gas=160000-8    	     100	  22326069 ns/op
BenchmarkOpAdd64-8                                            	10000000	       208 ns/op
BenchmarkOpAdd128-8                                           	 5000000	       224 ns/op
BenchmarkOpAdd256-8                                           	 5000000	       249 ns/op
BenchmarkOpSub64-8                                            	10000000	       238 ns/op
BenchmarkOpSub128-8                                           	 5000000	       294 ns/op
BenchmarkOpSub256-8                                           	 5000000	       414 ns/op
BenchmarkOpMul-8                                              	 3000000	       441 ns/op
BenchmarkOpDiv256-8                                           	 3000000	       774 ns/op
BenchmarkOpDiv128-8                                           	 5000000	       301 ns/op
BenchmarkOpDiv64-8                                            	 5000000	       261 ns/op
BenchmarkOpSdiv-8                                             	 2000000	       865 ns/op
BenchmarkOpMod-8                                              	 3000000	       538 ns/op
BenchmarkOpSmod-8                                             	 2000000	       851 ns/op
BenchmarkOpExp-8                                              	   50000	     32391 ns/op
BenchmarkOpSignExtend-8                                       	 3000000	       389 ns/op
BenchmarkOpLt-8                                               	 5000000	       360 ns/op
BenchmarkOpGt-8                                               	 5000000	       428 ns/op
BenchmarkOpSlt-8                                              	 2000000	       660 ns/op
BenchmarkOpSgt-8                                              	 2000000	       603 ns/op
BenchmarkOpEq-8                                               	 5000000	       363 ns/op
BenchmarkOpAnd-8                                              	 5000000	       365 ns/op
BenchmarkOpOr-8                                               	 5000000	       353 ns/op
BenchmarkOpXor-8                                              	 5000000	       356 ns/op
BenchmarkOpByte-8                                             	 5000000	       350 ns/op
BenchmarkOpAddmod-8                                           	 2000000	       819 ns/op
BenchmarkOpMulmod-8                                           	 1000000	      1012 ns/op
PASS
ok  	_/Users/timsiwula/Dropbox/Projects/go-ethereum/core/vm	101.361s
=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment