Skip to content

Commit a14e160

Browse files
(feat) added benchmarks for a simple Go installation (#191)
* (feat) added benchmarks for a simple Go installation * (fix) get me a number * (fix) get me a number * (docs) update README new badge * (fix) setup before
1 parent ba3e176 commit a14e160

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

.github/workflows/coveritup.yml

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ jobs:
4141
type: unit-test-run-time
4242
command: go test -race -v ./... -count=1 -coverprofile=coverage.out
4343
record: runtime
44+
- name: Benchmark Test
45+
uses: kevincobain2000/action-coveritup@v2
46+
with:
47+
type: allocs-per-op
48+
command: go test -count 1 -bench=. ./... -benchmem|grep allocs|awk '{ print $(--NF)}'
49+
record: score
50+
metric: alloc
4451

4552
- name: Coverage
4653
run: gocov convert coverage.out | gocov-xml > coverage.xml

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
![build-time](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=build-time&branch=master)
2828
![go-binary-size](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-binary-size&branch=master)
2929
![unit-test-run-time](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=unit-test-run-time&branch=master)
30+
![allocs-per-op](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=allocs-per-op&branch=master)
3031

3132
![go-mod-dependencies](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-mod-dependencies&branch=master)
3233
![go-sec-issues](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-sec-issues&branch=master)
@@ -37,7 +38,7 @@
3738
![go-mod-dependencies](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=go-mod-dependencies&branch=master&output=svg&width=160&height=160)
3839
![go-sec-issues](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=go-sec-issues&branch=master&output=svg&width=160&height=160&line=fill)
3940
![unit-test-run-time](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=unit-test-run-time&branch=master&output=svg&width=160&height=160)
40-
41+
![allocs-per-op](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=allocs-per-op&output=svg&width=160&height=160&branch=master)
4142

4243

4344

gobrew_test.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
)
1313

14-
func setupGobrew(t *testing.T, ts *httptest.Server) GoBrew {
14+
func setupGobrew[T testing.TB](t T, ts *httptest.Server) GoBrew {
1515
tags, _ := url.JoinPath(ts.URL, "golang-tags.json")
1616
versionURL, _ := url.JoinPath(ts.URL, "latest")
1717
config := Config{
@@ -25,6 +25,17 @@ func setupGobrew(t *testing.T, ts *httptest.Server) GoBrew {
2525
return gb
2626
}
2727

28+
func BenchmarkInstallGo(t *testing.B) {
29+
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
30+
gb := setupGobrew(t, ts)
31+
defer ts.Close()
32+
for i := 0; i < t.N; i++ {
33+
gb.Install("1.9")
34+
exists := gb.existsVersion("1.9")
35+
assert.Equal(t, true, exists)
36+
}
37+
}
38+
2839
func TestInstallAndExistVersion(t *testing.T) {
2940
t.Parallel()
3041
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))

0 commit comments

Comments
 (0)