From 447fc574e8cdde2d6d494f9e5794071d89f80d36 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 1 Jun 2023 15:27:19 +0200 Subject: [PATCH] Add query benchmark --- internal/repository/repository_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/repository/repository_test.go b/internal/repository/repository_test.go index 0aec9f6..efb5395 100644 --- a/internal/repository/repository_test.go +++ b/internal/repository/repository_test.go @@ -101,6 +101,30 @@ func BenchmarkDB_CountJobs(b *testing.B) { }) } +func BenchmarkDB_QueryJobs(b *testing.B) { + filter := &model.JobFilter{} + filter.State = append(filter.State, "running") + cluster := "fritz" + filter.Cluster = &model.StringInput{Eq: &cluster} + user := "mppi133h" + filter.User = &model.StringInput{Eq: &user} + page := &model.PageRequest{ItemsPerPage: 50, Page: 1} + order := &model.OrderByInput{Field: "startTime", Order: model.SortDirectionEnumDesc} + + b.Run("QueryJobs", func(b *testing.B) { + db := setup(b) + + b.ResetTimer() + + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + _, err := db.testQueryJobs([]*model.JobFilter{filter}, page, order) + noErr(b, err) + } + }) + }) +} + func setup(tb testing.TB) *JobRepository { tb.Helper() log.Init("warn", true)