返回 DeepSeek-Reasonix
bench_threshold_test.go
根目录 / internal / extension / bench_threshold_test.go
1 package extension
2
3 import (
4 "context"
5 "testing"
6 "time"
7 )
8
9 // Soft performance baselines for CI (not hard fails unless absurdly slow).
10 // These guard against multi-order-of-magnitude regressions on small graphs.
11 func TestGraphAndPlanLatencyBaseline(t *testing.T) {
12 comps := make([]ComponentDescriptor, 32)
13 for i := range comps {
14 comps[i] = ComponentDescriptor{ID: ComponentID("c" + itoa(i))}
15 }
16 start := time.Now()
17 g, err := BuildDependencyGraph(comps)
18 if err != nil {
19 t.Fatal(err)
20 }
21 if d := time.Since(start); d > 50*time.Millisecond {
22 t.Fatalf("BuildDependencyGraph(32) took %v, want < 50ms", d)
23 }
24 start = time.Now()
25 _ = DiffRuntimePlan(g, g, 1, 2)
26 if d := time.Since(start); d > 20*time.Millisecond {
27 t.Fatalf("DiffRuntimePlan no-op took %v, want < 20ms", d)
28 }
29 }
30
31 func TestEffectScopeDisposeBaseline(t *testing.T) {
32 s := NewEffectScope(1)
33 for i := range 64 {
34 id := "e" + itoa(i)
35 _ = s.Track(Effect{ID: id, Class: Reversible, Dispose: func(context.Context) error { return nil }})
36 }
37 start := time.Now()
38 if err := s.Dispose(context.Background()); err != nil {
39 t.Fatal(err)
40 }
41 if d := time.Since(start); d > 50*time.Millisecond {
42 t.Fatalf("Dispose(64) took %v, want < 50ms", d)
43 }
44 }
45
45 lines GO