File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
- 64cc0aa69d3ec38779a297042faf233beea5c405
1
+ 63a866e3c565fc326675a4051e3074bf542a9b0f
Original file line number Diff line number Diff line change @@ -7,8 +7,14 @@ import (
7
7
)
8
8
9
9
func TestPerformanceAnalyzer (t * testing.T ) {
10
- // Create a new performance analyzer
11
- analyzer := NewPerformanceAnalyzer ()
10
+ // Get the global performance analyzer and reset it to ensure clean state
11
+ analyzer := GetPerformanceAnalyzer ()
12
+ analyzer .Reset ()
13
+
14
+ // Ensure we restore previous state after test
15
+ defer func () {
16
+ analyzer .Reset ()
17
+ }()
12
18
13
19
// Test tracking a query
14
20
ctx := context .Background ()
@@ -27,6 +33,9 @@ func TestPerformanceAnalyzer(t *testing.T) {
27
33
t .Errorf ("Expected result to be 'test result', got %v" , result )
28
34
}
29
35
36
+ // Add a small delay to ensure async metrics update completes
37
+ time .Sleep (10 * time .Millisecond )
38
+
30
39
// Check metrics were collected
31
40
metrics := analyzer .GetAllMetrics ()
32
41
if len (metrics ) == 0 {
@@ -36,7 +45,7 @@ func TestPerformanceAnalyzer(t *testing.T) {
36
45
// Find the test query in metrics
37
46
var foundMetrics * QueryMetrics
38
47
for _ , m := range metrics {
39
- if m .Query == "SELECT * FROM test_table" {
48
+ if normalizeQuery ( m .Query ) == normalizeQuery ( "SELECT * FROM test_table" ) {
40
49
foundMetrics = m
41
50
break
42
51
}
You can’t perform that action at this time.
0 commit comments