Skip to content

Commit

Permalink
add benchmark
Browse files Browse the repository at this point in the history
goos: linux
goarch: amd64
pkg: github.com/fujiwara/tfstate-lookup/tfstate
cpu: AMD Ryzen 5 3400G with Radeon Vega Graphics
BenchmarkLookupFile-8               3056            374179 ns/op          210225 B/op       2549 allocs/op
PASS
  • Loading branch information
fujiwara committed Sep 17, 2024
1 parent de69972 commit 2ac40ae
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tfstate/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,25 @@ func TestLookupFileURL(t *testing.T) {
testLookupState(t, state)
}

func BenchmarkLookupFile(b *testing.B) {
f, err := os.Open("test/terraform.tfstate")
if err != nil {
b.Error(err)
}
state, err := tfstate.Read(context.Background(), f)
if err != nil {
b.Error(err)
}
for i := 0; i < b.N; i++ {
for _, ts := range TestSuitesOK {
_, err := state.Lookup(ts.Key)
if err != nil {
b.Error(err)
}
}
}
}

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

0 comments on commit 2ac40ae

Please sign in to comment.