mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-14 02:37:25 +01:00
Add query benchmark
This commit is contained in:
parent
65cebf6fde
commit
447fc574e8
@ -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 {
|
func setup(tb testing.TB) *JobRepository {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
log.Init("warn", true)
|
log.Init("warn", true)
|
||||||
|
Loading…
Reference in New Issue
Block a user