From 8ac351fd9c817212051665fc99d22340761415ac Mon Sep 17 00:00:00 2001 From: Kuisong Tong Date: Sat, 16 Mar 2024 18:29:27 -0700 Subject: [PATCH] fix benchmark cache key (#249) --- .github/workflows/benchmark.yml | 2 +- benchmark_test.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 132cebb4..20762f7f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -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 diff --git a/benchmark_test.go b/benchmark_test.go index 6efba66e..99294b80 100644 --- a/benchmark_test.go +++ b/benchmark_test.go @@ -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) @@ -60,3 +58,7 @@ func BenchmarkUnmarshal(b *testing.B) { } }) } + +type Value struct { + User string +}