Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/benchdiff/internal/benchdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io"
Expand All @@ -11,6 +12,7 @@ import (
"strings"

"github.com/willabides/benchdiff/pkg/benchstatter"
"golang.org/x/crypto/sha3"
"golang.org/x/perf/benchstat"
)

Expand Down Expand Up @@ -59,6 +61,14 @@ func (c *Benchdiff) baseRefRunner() *refRunner {
}
}

func (c *Benchdiff) cacheKey() string {
var b []byte
b = append(b, []byte(c.BenchCmd)...)
b = append(b, []byte(c.BenchArgs)...)
sum := sha3.Sum224(b)
return base64.RawURLEncoding.EncodeToString(sum[:])
}

func (c *Benchdiff) runBenchmarks() (result *runBenchmarksResults, err error) {
result = new(runBenchmarksResults)
worktreeFilename := filepath.Join(c.ResultsDir, "benchdiff-worktree.out")
Expand Down Expand Up @@ -90,7 +100,7 @@ func (c *Benchdiff) runBenchmarks() (result *runBenchmarksResults, err error) {
return nil, err
}

baseFilename := fmt.Sprintf("benchdiff-%s.out", baseSHA)
baseFilename := fmt.Sprintf("benchdiff-%s-%s.out", baseSHA, c.cacheKey())
baseFilename = filepath.Join(c.ResultsDir, baseFilename)
result.headSHA = headSHA
result.baseSHA = baseSHA
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ go 1.15
require (
github.com/alecthomas/kong v0.2.12
github.com/stretchr/testify v1.5.1
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/perf v0.0.0-20201207232921-bdcc6220ee90
)
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand Down