Skip to content

Commit 916a7c4

Browse files
committed
add badges and re-run all benchmarks (go1.17.2 on intel mac (i7-6920HQ))
1 parent df79e41 commit 916a7c4

File tree

3 files changed

+88
-70
lines changed

3 files changed

+88
-70
lines changed

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Simon Waldherr
3+
Copyright (c) 2021 Simon Waldherr
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: README.md

+84-69
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Go Benchmarks
22

3+
[![Go Report Card](https://goreportcard.com/badge/github.com/SimonWaldherr/golang-benchmarks)](https://goreportcard.com/report/github.com/SimonWaldherr/golang-benchmarks)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
5+
36
In programming in general, and in Golang in particular, many roads lead to Rome.
47
From time to time I ask myself which of these ways is the fastest.
58
In Golang there is a wonderful solution, with `go test -bench` you can measure the speed very easily and quickly.
@@ -37,7 +40,7 @@ If you\'re interested in new programming languages, you should definitely take a
3740

3841
## Benchmark Results
3942

40-
Golang Version: go version go1.14 darwin/amd64
43+
Golang Version: go version go1.17.2 darwin/amd64
4144

4245
### base64
4346

@@ -88,10 +91,11 @@ func BenchmarkBase64regex(b *testing.B) {
8891
$ go test -bench . -benchmem
8992
goos: darwin
9093
goarch: amd64
91-
BenchmarkBase64decode-8 7254507 156 ns/op 40 B/op 3 allocs/op
92-
BenchmarkBase64regex-8 48475 25091 ns/op 21450 B/op 198 allocs/op
94+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
95+
BenchmarkBase64decode-8 9560068 118.0 ns/op 32 B/op 2 allocs/op
96+
BenchmarkBase64regex-8 57950 20319 ns/op 21378 B/op 198 allocs/op
9397
PASS
94-
ok _/Users/simonwaldherr/git/golang-benchmarks/base64 2.928s
98+
ok _/Users/simonwaldherr/git/golang-benchmarks/base64 2.810s
9599
```
96100

97101
### between
@@ -183,12 +187,13 @@ func BenchmarkFulltextParse(b *testing.B) {
183187
$ go test -bench . -benchmem
184188
goos: darwin
185189
goarch: amd64
186-
BenchmarkNumberRegEx-8 65848 16709 ns/op 16119 B/op 142 allocs/op
187-
BenchmarkFulltextRegEx-8 93330 13651 ns/op 11596 B/op 104 allocs/op
188-
BenchmarkNumberParse-8 15222080 79.5 ns/op 0 B/op 0 allocs/op
189-
BenchmarkFulltextParse-8 1000000 1172 ns/op 32 B/op 2 allocs/op
190+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
191+
BenchmarkNumberRegEx-8 83380 14132 ns/op 16108 B/op 142 allocs/op
192+
BenchmarkFulltextRegEx-8 106365 11374 ns/op 11583 B/op 104 allocs/op
193+
BenchmarkNumberParse-8 19983571 58.39 ns/op 0 B/op 0 allocs/op
194+
BenchmarkFulltextParse-8 1286323 925.7 ns/op 32 B/op 2 allocs/op
190195
PASS
191-
ok _/Users/simonwaldherr/git/golang-benchmarks/between 5.338s
196+
ok _/Users/simonwaldherr/git/golang-benchmarks/between 6.179s
192197
```
193198

194199
### concat
@@ -234,11 +239,12 @@ func BenchmarkConcatBuilder(b *testing.B) {
234239
$ go test -bench . -benchmem
235240
goos: darwin
236241
goarch: amd64
237-
BenchmarkConcatString-8 762847 51951 ns/op 385387 B/op 1 allocs/op
238-
BenchmarkConcatBuffer-8 137992653 8.01 ns/op 3 B/op 0 allocs/op
239-
BenchmarkConcatBuilder-8 360238653 5.07 ns/op 5 B/op 0 allocs/op
242+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
243+
BenchmarkConcatString-8 1000000 52240 ns/op 503994 B/op 1 allocs/op
244+
BenchmarkConcatBuffer-8 209196111 5.813 ns/op 2 B/op 0 allocs/op
245+
BenchmarkConcatBuilder-8 570164085 4.139 ns/op 5 B/op 0 allocs/op
240246
PASS
241-
ok _/Users/simonwaldherr/git/golang-benchmarks/concat 44.077s
247+
ok _/Users/simonwaldherr/git/golang-benchmarks/concat 56.945s
242248
```
243249

244250
### contains
@@ -388,16 +394,17 @@ func BenchmarkMatchNot(b *testing.B) {
388394
$ go test -bench . -benchmem
389395
goos: darwin
390396
goarch: amd64
391-
BenchmarkContains-8 115778936 10.1 ns/op 0 B/op 0 allocs/op
392-
BenchmarkContainsNot-8 99892357 12.6 ns/op 0 B/op 0 allocs/op
393-
BenchmarkContainsBytes-8 100000000 11.9 ns/op 0 B/op 0 allocs/op
394-
BenchmarkContainsBytesNot-8 88537238 14.1 ns/op 0 B/op 0 allocs/op
395-
BenchmarkCompileMatch-8 11208225 112 ns/op 0 B/op 0 allocs/op
396-
BenchmarkCompileMatchNot-8 21716254 59.3 ns/op 0 B/op 0 allocs/op
397-
BenchmarkMatch-8 700544 1705 ns/op 1366 B/op 17 allocs/op
398-
BenchmarkMatchNot-8 721296 1627 ns/op 1366 B/op 17 allocs/op
397+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
398+
BenchmarkContains-8 99957616 10.04 ns/op 0 B/op 0 allocs/op
399+
BenchmarkContainsNot-8 134844804 8.823 ns/op 0 B/op 0 allocs/op
400+
BenchmarkContainsBytes-8 100000000 10.44 ns/op 0 B/op 0 allocs/op
401+
BenchmarkContainsBytesNot-8 130119946 9.305 ns/op 0 B/op 0 allocs/op
402+
BenchmarkCompileMatch-8 13544917 87.23 ns/op 0 B/op 0 allocs/op
403+
BenchmarkCompileMatchNot-8 27381130 44.71 ns/op 0 B/op 0 allocs/op
404+
BenchmarkMatch-8 706044 1490 ns/op 1362 B/op 17 allocs/op
405+
BenchmarkMatchNot-8 855297 1426 ns/op 1362 B/op 17 allocs/op
399406
PASS
400-
ok _/Users/simonwaldherr/git/golang-benchmarks/contains 11.943s
407+
ok _/Users/simonwaldherr/git/golang-benchmarks/contains 11.398s
401408
```
402409

403410
### foreach
@@ -484,12 +491,13 @@ func BenchmarkRangeSliceKey(b *testing.B) {
484491
$ go test -bench . -benchmem
485492
goos: darwin
486493
goarch: amd64
487-
BenchmarkForMap-8 40688367 29.5 ns/op 0 B/op 0 allocs/op
488-
BenchmarkRangeMap-8 13963262 82.0 ns/op 0 B/op 0 allocs/op
489-
BenchmarkRangeSlice-8 298244845 4.02 ns/op 0 B/op 0 allocs/op
490-
BenchmarkRangeSliceKey-8 283311711 4.16 ns/op 0 B/op 0 allocs/op
494+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
495+
BenchmarkForMap-8 46394040 25.52 ns/op 0 B/op 0 allocs/op
496+
BenchmarkRangeMap-8 16615866 73.11 ns/op 0 B/op 0 allocs/op
497+
BenchmarkRangeSlice-8 285213235 4.210 ns/op 0 B/op 0 allocs/op
498+
BenchmarkRangeSliceKey-8 365047436 3.296 ns/op 0 B/op 0 allocs/op
491499
PASS
492-
ok _/Users/simonwaldherr/git/golang-benchmarks/foreach 5.934s
500+
ok _/Users/simonwaldherr/git/golang-benchmarks/foreach 5.824s
493501
```
494502

495503
### hash
@@ -599,22 +607,23 @@ func BenchmarkWhirlpool(b *testing.B) {
599607
$ go test -bench . -benchmem
600608
goos: darwin
601609
goarch: amd64
602-
BenchmarkAdler32-8 1320891 941 ns/op 8 B/op 1 allocs/op
603-
BenchmarkBlake2b256-8 478911 2633 ns/op 32 B/op 1 allocs/op
604-
BenchmarkBlake2b512-8 481056 2445 ns/op 64 B/op 1 allocs/op
605-
BenchmarkBlake3256-8 387159 3669 ns/op 64 B/op 2 allocs/op
606-
BenchmarkMMH3-8 1922512 615 ns/op 16 B/op 1 allocs/op
607-
BenchmarkCRC32-8 7177801 156 ns/op 8 B/op 1 allocs/op
608-
BenchmarkFnv128-8 228894 5273 ns/op 16 B/op 1 allocs/op
609-
BenchmarkMD5-8 359323 3214 ns/op 16 B/op 1 allocs/op
610-
BenchmarkSHA1-8 412834 2653 ns/op 32 B/op 1 allocs/op
611-
BenchmarkSHA256-8 208404 5920 ns/op 32 B/op 1 allocs/op
612-
BenchmarkSHA512-8 304238 4086 ns/op 64 B/op 1 allocs/op
613-
BenchmarkSHA3256-8 163845 7918 ns/op 512 B/op 3 allocs/op
614-
BenchmarkSHA3512-8 93015 13573 ns/op 576 B/op 3 allocs/op
615-
BenchmarkWhirlpool-8 16759 71602 ns/op 64 B/op 1 allocs/op
610+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
611+
BenchmarkAdler32-8 1412611 830.5 ns/op 8 B/op 1 allocs/op
612+
BenchmarkBlake2b256-8 516076 2365 ns/op 32 B/op 1 allocs/op
613+
BenchmarkBlake2b512-8 513266 2379 ns/op 64 B/op 1 allocs/op
614+
BenchmarkBlake3256-8 395769 3204 ns/op 64 B/op 2 allocs/op
615+
BenchmarkMMH3-8 2603317 463.3 ns/op 16 B/op 1 allocs/op
616+
BenchmarkCRC32-8 8232622 144.8 ns/op 8 B/op 1 allocs/op
617+
BenchmarkFnv128-8 231744 5096 ns/op 16 B/op 1 allocs/op
618+
BenchmarkMD5-8 382044 3121 ns/op 16 B/op 1 allocs/op
619+
BenchmarkSHA1-8 505125 2511 ns/op 24 B/op 1 allocs/op
620+
BenchmarkSHA256-8 207714 5596 ns/op 32 B/op 1 allocs/op
621+
BenchmarkSHA512-8 288182 4275 ns/op 64 B/op 1 allocs/op
622+
BenchmarkSHA3256-8 168361 7126 ns/op 512 B/op 3 allocs/op
623+
BenchmarkSHA3512-8 95119 12676 ns/op 576 B/op 3 allocs/op
624+
BenchmarkWhirlpool-8 22759 50342 ns/op 64 B/op 1 allocs/op
616625
PASS
617-
ok _/Users/simonwaldherr/git/golang-benchmarks/hash 20.138s
626+
ok _/Users/simonwaldherr/git/golang-benchmarks/hash 19.542s
618627
```
619628

620629
### index
@@ -697,10 +706,11 @@ func BenchmarkMapIntKeys(b *testing.B) {
697706
$ go test -bench . -benchmem
698707
goos: darwin
699708
goarch: amd64
700-
BenchmarkMapStringKeys-8 9294176 123 ns/op 0 B/op 0 allocs/op
701-
BenchmarkMapIntKeys-8 13910860 83.8 ns/op 0 B/op 0 allocs/op
709+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
710+
BenchmarkMapStringKeys-8 10229023 115.0 ns/op 0 B/op 0 allocs/op
711+
BenchmarkMapIntKeys-8 17356731 70.59 ns/op 0 B/op 0 allocs/op
702712
PASS
703-
ok _/Users/simonwaldherr/git/golang-benchmarks/index 4.156s
713+
ok _/Users/simonwaldherr/git/golang-benchmarks/index 3.997s
704714
```
705715

706716
### json
@@ -791,10 +801,11 @@ func BenchmarkJsonUnmarshal(b *testing.B) {
791801
$ go test -bench . -benchmem
792802
goos: darwin
793803
goarch: amd64
794-
BenchmarkJsonMarshal-8 453858 2461 ns/op 480 B/op 5 allocs/op
795-
BenchmarkJsonUnmarshal-8 115800 10627 ns/op 2128 B/op 38 allocs/op
804+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
805+
BenchmarkJsonMarshal-8 704182 1692 ns/op 480 B/op 5 allocs/op
806+
BenchmarkJsonUnmarshal-8 170817 7015 ns/op 2136 B/op 39 allocs/op
796807
PASS
797-
ok _/Users/simonwaldherr/git/golang-benchmarks/json 2.646s
808+
ok _/Users/simonwaldherr/git/golang-benchmarks/json 3.513s
798809
```
799810

800811
### math
@@ -877,16 +888,17 @@ func BenchmarkMathFloat64(b *testing.B) {
877888
$ go test -bench . -benchmem
878889
goos: darwin
879890
goarch: amd64
880-
BenchmarkMathInt8-8 1000000000 0.357 ns/op 0 B/op 0 allocs/op
881-
BenchmarkMathInt32-8 1000000000 0.318 ns/op 0 B/op 0 allocs/op
882-
BenchmarkMathInt64-8 1000000000 0.304 ns/op 0 B/op 0 allocs/op
883-
BenchmarkMathAtomicInt32-8 220301023 5.70 ns/op 0 B/op 0 allocs/op
884-
BenchmarkMathAtomicInt64-8 213277671 5.57 ns/op 0 B/op 0 allocs/op
885-
BenchmarkMathMutexInt-8 77317648 18.0 ns/op 0 B/op 0 allocs/op
886-
BenchmarkMathFloat32-8 1000000000 0.630 ns/op 0 B/op 0 allocs/op
887-
BenchmarkMathFloat64-8 1000000000 0.624 ns/op 0 B/op 0 allocs/op
891+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
892+
BenchmarkMathInt8-8 1000000000 0.2968 ns/op 0 B/op 0 allocs/op
893+
BenchmarkMathInt32-8 1000000000 0.2962 ns/op 0 B/op 0 allocs/op
894+
BenchmarkMathInt64-8 1000000000 0.3032 ns/op 0 B/op 0 allocs/op
895+
BenchmarkMathAtomicInt32-8 227491854 5.259 ns/op 0 B/op 0 allocs/op
896+
BenchmarkMathAtomicInt64-8 224599971 5.256 ns/op 0 B/op 0 allocs/op
897+
BenchmarkMathMutexInt-8 80323725 15.24 ns/op 0 B/op 0 allocs/op
898+
BenchmarkMathFloat32-8 1000000000 0.2957 ns/op 0 B/op 0 allocs/op
899+
BenchmarkMathFloat64-8 1000000000 0.2930 ns/op 0 B/op 0 allocs/op
888900
PASS
889-
ok _/Users/simonwaldherr/git/golang-benchmarks/math 7.624s
901+
ok _/Users/simonwaldherr/git/golang-benchmarks/math 6.524s
890902
```
891903

892904
### parse
@@ -932,11 +944,12 @@ func BenchmarkParseFloat(b *testing.B) {
932944
$ go test -bench . -benchmem
933945
goos: darwin
934946
goarch: amd64
935-
BenchmarkParseBool-8 552503154 2.02 ns/op 0 B/op 0 allocs/op
936-
BenchmarkParseInt-8 50780764 23.8 ns/op 0 B/op 0 allocs/op
937-
BenchmarkParseFloat-8 9560934 125 ns/op 0 B/op 0 allocs/op
947+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
948+
BenchmarkParseBool-8 1000000000 0.4423 ns/op 0 B/op 0 allocs/op
949+
BenchmarkParseInt-8 78935926 15.23 ns/op 0 B/op 0 allocs/op
950+
BenchmarkParseFloat-8 13413082 84.53 ns/op 0 B/op 0 allocs/op
938951
PASS
939-
ok _/Users/simonwaldherr/git/golang-benchmarks/parse 4.053s
952+
ok _/Users/simonwaldherr/git/golang-benchmarks/parse 3.094s
940953
```
941954

942955
### random
@@ -999,11 +1012,12 @@ func GenerateRandomString(s int) (string, error) {
9991012
$ go test -bench . -benchmem
10001013
goos: darwin
10011014
goarch: amd64
1002-
BenchmarkMathRand-8 45860341 27.2 ns/op 0 B/op 0 allocs/op
1003-
BenchmarkCryptoRand-8 6705362 175 ns/op 56 B/op 4 allocs/op
1004-
BenchmarkCryptoRandString-8 5791434 208 ns/op 128 B/op 3 allocs/op
1015+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
1016+
BenchmarkMathRand-8 42785676 24.88 ns/op 0 B/op 0 allocs/op
1017+
BenchmarkCryptoRand-8 1311817 911.6 ns/op 56 B/op 4 allocs/op
1018+
BenchmarkCryptoRandString-8 7548224 159.2 ns/op 128 B/op 3 allocs/op
10051019
PASS
1006-
ok _/Users/simonwaldherr/git/golang-benchmarks/random 4.205s
1020+
ok _/Users/simonwaldherr/git/golang-benchmarks/random 4.737s
10071021
```
10081022

10091023
### regexp
@@ -1057,10 +1071,11 @@ func BenchmarkMatchStringGolibs(b *testing.B) {
10571071
$ go test -bench . -benchmem
10581072
goos: darwin
10591073
goarch: amd64
1060-
BenchmarkMatchString-8 109479 9868 ns/op 9956 B/op 86 allocs/op
1061-
BenchmarkMatchStringCompiled-8 1579666 792 ns/op 0 B/op 0 allocs/op
1062-
BenchmarkMatchStringGolibs-8 1776057 677 ns/op 0 B/op 0 allocs/op
1074+
cpu: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
1075+
BenchmarkMatchString-8 132502 8866 ns/op 9969 B/op 86 allocs/op
1076+
BenchmarkMatchStringCompiled-8 2188528 528.4 ns/op 0 B/op 0 allocs/op
1077+
BenchmarkMatchStringGolibs-8 2206384 549.3 ns/op 0 B/op 0 allocs/op
10631078
PASS
1064-
ok _/Users/simonwaldherr/git/golang-benchmarks/regexp 5.251s
1079+
ok _/Users/simonwaldherr/git/golang-benchmarks/regexp 4.924s
10651080
```
10661081

Diff for: updateBenchLogs.sh

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ declare -a benchs=(base64 between concat contains foreach hash index json math p
55
cat > README.md <<- EOM
66
# Go Benchmarks
77
8+
[![Go Report Card](https://goreportcard.com/badge/github.com/SimonWaldherr/golang-benchmarks)](https://goreportcard.com/report/github.com/SimonWaldherr/golang-benchmarks)
9+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
10+
811
In programming in general, and in Golang in particular, many roads lead to Rome.
912
From time to time I ask myself which of these ways is the fastest.
1013
In Golang there is a wonderful solution, with \`go test -bench\` you can measure the speed very easily and quickly.

0 commit comments

Comments
 (0)