(b *testing.B)
| 590 | } |
| 591 | |
| 592 | func BenchmarkTemporalStore_GetFactsDuring(b *testing.B) { |
| 593 | store := factstore.NewTemporalStore() |
| 594 | |
| 595 | // Add many facts |
| 596 | for i := 0; i < 10000; i++ { |
| 597 | atomName, _ := ast.Name("/item" + string(rune('0'+i%100))) |
| 598 | store.Add(ast.NewAtom("available", atomName), ast.TimeInterval( |
| 599 | time.Date(2024, 1, 1+i%28, 0, 0, 0, 0, time.UTC), |
| 600 | time.Date(2024, 2, 1+i%28, 0, 0, 0, 0, time.UTC), |
| 601 | )) |
| 602 | } |
| 603 | |
| 604 | query := ast.NewAtom("available", ast.Variable{Symbol: "X"}) |
| 605 | interval := ast.TimeInterval( |
| 606 | ast.Date(2024, 1, 10), |
| 607 | ast.Date(2024, 1, 20), |
| 608 | ) |
| 609 | |
| 610 | b.ResetTimer() |
| 611 | for i := 0; i < b.N; i++ { |
| 612 | count := 0 |
| 613 | store.GetFactsDuring(query, interval, func(tf factstore.TemporalFact) error { |
| 614 | count++ |
| 615 | return nil |
| 616 | }) |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | func BenchmarkIntervalCoalesce(b *testing.B) { |
| 621 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no test coverage detected