Skip to content

Commit

Permalink
fix benchmark cache key (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong authored Mar 17, 2024
1 parent e39af8c commit 8ac351f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-{{ github.sha }}
key: ${{ runner.os }}-benchmark-${{ github.sha }}
restore-keys: |
${{ runner.os }}-benchmark
- name: Store benchmark result
Expand Down
12 changes: 7 additions & 5 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ func BenchmarkLoad(b *testing.B) {
}

func BenchmarkGet(b *testing.B) {
assert.Equal(b, os.Getenv("USER"), konf.Get[string]("user"))
assert.Equal(b, os.Getenv("USER"), konf.Get[Value]("").User)

b.ReportAllocs()
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = konf.Get[string]("user")
_ = konf.Get[Value]("")
}
})
}

func BenchmarkUnmarshal(b *testing.B) {
var value struct {
User string
}
var value Value
err := konf.Unmarshal("", &value)
assert.NoError(b, err)
assert.Equal(b, os.Getenv("USER"), value.User)
Expand All @@ -60,3 +58,7 @@ func BenchmarkUnmarshal(b *testing.B) {
}
})
}

type Value struct {
User string
}

1 comment on commit 8ac351f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 8ac351f Previous: beef991 Ratio
BenchmarkLoad 301.7 ns/op 872 B/op 6 allocs/op 487.3 ns/op 0.62
BenchmarkLoad - ns/op 301.7 ns/op
BenchmarkLoad - B/op 872 B/op
BenchmarkLoad - allocs/op 6 allocs/op
BenchmarkGet 218.5 ns/op 64 B/op 5 allocs/op 200.7 ns/op 1.09
BenchmarkGet - ns/op 218.5 ns/op
BenchmarkGet - B/op 64 B/op
BenchmarkGet - allocs/op 5 allocs/op
BenchmarkUnmarshal 200 ns/op 48 B/op 4 allocs/op 174.5 ns/op 1.15
BenchmarkUnmarshal - ns/op 200 ns/op
BenchmarkUnmarshal - B/op 48 B/op
BenchmarkUnmarshal - allocs/op 4 allocs/op

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.