Skip to content

Commit

Permalink
(feat) added benchmarks for a simple Go installation (#191)
Browse files Browse the repository at this point in the history
* (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
  • Loading branch information
kevincobain2000 committed Apr 7, 2024
1 parent ba3e176 commit a14e160
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/coveritup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ jobs:
type: unit-test-run-time
command: go test -race -v ./... -count=1 -coverprofile=coverage.out
record: runtime
- name: Benchmark Test
uses: kevincobain2000/action-coveritup@v2
with:
type: allocs-per-op
command: go test -count 1 -bench=. ./... -benchmem|grep allocs|awk '{ print $(--NF)}'
record: score
metric: alloc

- name: Coverage
run: gocov convert coverage.out | gocov-xml > coverage.xml
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
![build-time](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=build-time&branch=master)
![go-binary-size](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-binary-size&branch=master)
![unit-test-run-time](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=unit-test-run-time&branch=master)
![allocs-per-op](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=allocs-per-op&branch=master)

![go-mod-dependencies](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-mod-dependencies&branch=master)
![go-sec-issues](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-sec-issues&branch=master)
Expand All @@ -37,7 +38,7 @@
![go-mod-dependencies](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=go-mod-dependencies&branch=master&output=svg&width=160&height=160)
![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)
![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)

![allocs-per-op](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=allocs-per-op&output=svg&width=160&height=160&branch=master)



Expand Down
13 changes: 12 additions & 1 deletion gobrew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/assert"
)

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

func BenchmarkInstallGo(t *testing.B) {
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
gb := setupGobrew(t, ts)
defer ts.Close()
for i := 0; i < t.N; i++ {
gb.Install("1.9")
exists := gb.existsVersion("1.9")
assert.Equal(t, true, exists)
}
}

func TestInstallAndExistVersion(t *testing.T) {
t.Parallel()
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
Expand Down

0 comments on commit a14e160

Please sign in to comment.