(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestPoolStats_ConcurrentSafe(t *testing.T) { |
| 103 | metrics.ResetPoolStats() |
| 104 | |
| 105 | done := make(chan struct{}) |
| 106 | for i := 0; i < 100; i++ { |
| 107 | go func() { |
| 108 | metrics.RecordNamedPoolGet("tokenizer") |
| 109 | metrics.RecordNamedPoolPut("tokenizer") |
| 110 | done <- struct{}{} |
| 111 | }() |
| 112 | } |
| 113 | for i := 0; i < 100; i++ { |
| 114 | <-done |
| 115 | } |
| 116 | |
| 117 | stats := metrics.GetPoolStats() |
| 118 | ts := stats["tokenizer"] |
| 119 | if ts.Gets != 100 { |
| 120 | t.Errorf("expected Gets=100, got %d", ts.Gets) |
| 121 | } |
| 122 | if ts.Puts != 100 { |
| 123 | t.Errorf("expected Puts=100, got %d", ts.Puts) |
| 124 | } |
| 125 | } |
nothing calls this directly
no test coverage detected