Skip to content

Instantly share code, notes, and snippets.

@shibukawa
Created December 3, 2020 02:10
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 shibukawa/601fa966f433025ad46e06045361ca2c to your computer and use it in GitHub Desktop.
Save shibukawa/601fa966f433025ad46e06045361ca2c to your computer and use it in GitHub Desktop.
ベンチマーク実行: git@github.com:SimonWaldherr/golang-benchmarks.git
import re
text='''
BenchmarkBase64decode-8 15848164 75.52 ns/op
BenchmarkBase64regex-8 90501 13271 ns/op
BenchmarkNumberRegEx-8 138379 8616 ns/op
BenchmarkFulltextRegEx-8 158005 7098 ns/op
BenchmarkNumberParse-8 21333996 54.91 ns/op
BenchmarkFulltextParse-8 1500830 783.4 ns/op
BenchmarkConcatString-8 1000000 23788 ns/op
BenchmarkConcatBuffer-8 249271357 4.792 ns/op
BenchmarkConcatBuilder-8 461805702 2.662 ns/op
BenchmarkContains-8 213667952 5.465 ns/op
BenchmarkContainsNot-8 171611827 6.993 ns/op
BenchmarkContainsBytes-8 185895188 6.198 ns/op
BenchmarkContainsBytesNot-8 156198654 7.740 ns/op
BenchmarkCompileMatch-8 14882551 80.40 ns/op
BenchmarkCompileMatchNot-8 33228685 35.95 ns/op
BenchmarkMatch-8 1354120 870.8 ns/op
BenchmarkMatchNot-8 1450808 837.3 ns/op
BenchmarkForMap-8 55120460 20.56 ns/op
BenchmarkRangeMap-8 22125847 55.31 ns/op
BenchmarkRangeSlice-8 308708306 3.800 ns/op
BenchmarkRangeSliceKey-8 258507151 4.528 ns/op
BenchmarkAdler32-8 1559053 764.9 ns/op
BenchmarkBlake2b256-8 456589 2612 ns/op
BenchmarkBlake2b512-8 463735 2626 ns/op
BenchmarkBlake3256-8 194734 6339 ns/op
BenchmarkMMH3-8 2793075 413.4 ns/op
BenchmarkCRC32-8 1000000 1098 ns/op
BenchmarkFnv128-8 249662 4924 ns/op
BenchmarkMD5-8 345543 3566 ns/op
BenchmarkSHA1-8 201534 5789 ns/op
BenchmarkSHA256-8 106111 10865 ns/op
BenchmarkSHA512-8 158274 7801 ns/op
BenchmarkSHA3256-8 254842 4575 ns/op
BenchmarkSHA3512-8 145797 7929 ns/op
BenchmarkWhirlpool-8 34024 35819 ns/op
BenchmarkMapStringKeys-8 14003095 82.45 ns/op
BenchmarkMapIntKeys-8 24633849 49.72 ns/op
BenchmarkJsonMarshal-8 808806 1422 ns/op
BenchmarkJsonUnmarshal-8 215998 5496 ns/op
BenchmarkMathInt8-8 1000000000 0.3465 ns/op
BenchmarkMathInt32-8 1000000000 0.3505 ns/op
BenchmarkMathInt64-8 1000000000 0.3558 ns/op
BenchmarkMathAtomicInt32-8 171393200 7.132 ns/op
BenchmarkMathAtomicInt64-8 172797321 7.070 ns/op
BenchmarkMathMutexInt-8 93238585 12.45 ns/op
BenchmarkMathFloat32-8 1000000000 0.3594 ns/op
BenchmarkMathFloat64-8 1000000000 0.3551 ns/op
BenchmarkParseBool-8 787011038 1.598 ns/op
BenchmarkParseInt-8 98798974 12.31 ns/op
BenchmarkParseFloat-8 17198331 72.39 ns/op
BenchmarkMathRand-8 95200951 12.82 ns/op
BenchmarkCryptoRand-8 11372740 109.9 ns/op
BenchmarkCryptoRandString-8 9814508 119.1 ns/op
BenchmarkMatchString-8 216518 5371 ns/op
BenchmarkMatchStringCompiled-8 2304112 529.2 ns/op
BenchmarkMatchStringGolibs-8 2282424 523.5 ns/op
'''
m = re.compile(r'\s+')
for line in text.split('\n'):
result = m.split(line)
if len(result) != 4:
continue
print(f'{result[0]}\t{result[2]}')
import subprocess
import pathlib
dirs = [
'base64',
'between',
'concat',
'contains',
'foreach',
'hash',
'index',
'json',
'math',
'parse',
'random',
'regexp',
]
compilers = [
'/opt/local/go/bin/go',
# '/Users/shibukawayoshiki/develop/go-darwin-amd64-bootstrap/bin/go',
]
for i, dirname in enumerate(dirs):
cwd = pathlib.Path('.', dirname)
for c in compilers:
print(f'{dirname} {i+1}/{len(dirs)}')
subprocess.call(f'{c} test -bench .', cwd=cwd, shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment