-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathupdateBenchLogs.sh
More file actions
executable file
·94 lines (74 loc) · 3.46 KB
/
updateBenchLogs.sh
File metadata and controls
executable file
·94 lines (74 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
declare -a benchs=(base64 between caseinsensitivecompare concat contains concurrency_counter embed floodfill foreach hash index json math parse random regexp sql template trim)
cat > README.md <<- EOM
# Go Benchmarks
[](https://zenodo.org/badge/latestdoi/154216722)
[](https://goreportcard.com/report/github.com/SimonWaldherr/golang-benchmarks)
[](https://opensource.org/licenses/MIT)
In programming in general, and in Golang in particular, many roads lead to Rome.
From time to time I ask myself which of these ways is the fastest.
In Golang there is a wonderful solution, with \`go test -bench\` you can measure the speed very easily and quickly.
In order for you to benefit from it too, I will publish such benchmarks in this repository in the future.
## ToC
EOM
for i in "${benchs[@]}"
do
echo "* [$i](https://github.com/SimonWaldherr/golang-benchmarks#$i)" >> README.md
done
cat >> README.md <<- EOM
## Golang?
I published another repository where I show some Golang examples.
If you\'re interested in new programming languages, you should definitely take a look at Golang:
* [Golang examples](https://github.com/SimonWaldherr/golang-examples)
* [tour.golang.org](https://tour.golang.org/)
* [Go by example](https://gobyexample.com/)
* [Golang Book](http://www.golang-book.com/)
* [Go-Learn](https://github.com/skippednote/Go-Learn)
## Is it any good?
[Yes](https://news.ycombinator.com/item?id=3067434)
## Benchmark Results
EOM
go fmt ./...
echo -n "Golang Version: " >> README.md
go version >> README.md
echo "" >> README.md
for i in "${benchs[@]}"
do
cd "$i"
# skip packages without test files
if ! ls *_test.go >/dev/null 2>&1; then
cd ..
continue
fi
gofmt -s -w -l -e .
echo "### $i" >> ../README.md
echo >> ../README.md
echo "\`\`\`go" >> ../README.md
cat *_test.go >> ../README.md
echo "\`\`\`" >> ../README.md
echo >> ../README.md
echo "\`\`\`" >> ../README.md
echo "$ go test -bench . -benchmem" >> ../README.md
go test -bench . -benchmem >> ../README.md
echo "\`\`\`" >> ../README.md
echo >> ../README.md
# If package is sql, also attempt tinysql-tagged benchmarks (optional)
if [ "$i" = "sql" ]; then
echo "### sql (tinysql)" >> ../README.md
echo >> ../README.md
echo "\`\`\`go" >> ../README.md
cat *_test.go >> ../README.md
echo "\`\`\`" >> ../README.md
echo >> ../README.md
echo "\`\`\`" >> ../README.md
echo "$ go test -bench . -benchmem -tags tinysql" >> ../README.md
if go test -bench . -benchmem -tags tinysql >> ../README.md 2>&1; then
:
else
echo "(tinysql benchmarks skipped or failed)" >> ../README.md
fi
echo "\`\`\`" >> ../README.md
echo >> ../README.md
fi
cd ..
done