on main help sign in
fix: format internal/lsp/watcher/watcher_performance_test.go
commit052f54c87f86a2b37a138ee11b3ec8a80ee8fdea authorRaphael Amorim <rapha850@gmail.com> dateMon 16 Jun 2025, 12:45 (1 year ago) parent8ea7890
1 file changed+10−10
internal/lsp/watcher/watcher_performance_test.go+10−10
internal/lsp/watcher/watcher_performance_test.go+10−10
@@ -19,7 +19,7 @@ func createTestWorkspace(tb testing.TB) string {
1919 // Create test files for Go project
2020 testFiles := []string{
2121 "go.mod",
22− "go.sum",
22+ "go.sum",
2323 "main.go",
2424 "src/lib.go",
2525 "src/utils.go",
@@ -38,11 +38,11 @@ func createTestWorkspace(tb testing.TB) string {
3838 for _, file := range testFiles {
3939 fullPath := filepath.Join(tmpDir, file)
4040 dir := filepath.Dir(fullPath)
41−
41+
4242 if err := os.MkdirAll(dir, 0755); err != nil {
4343 tb.Fatal(err)
4444 }
45−
45+
4646 if err := os.WriteFile(fullPath, []byte("// test content"), 0644); err != nil {
4747 tb.Fatal(err)
4848 }
@@ -128,7 +128,7 @@ func simulateNewApproach(workspacePath string, serverName string) (int, time.Dur
128128
129129 // NEW APPROACH: Collect all files first
130130 var filesToOpen []string
131−
131+
132132 // For each pattern, find matching files
133133 for _, pattern := range patterns {
134134 matches, err := doublestar.Glob(os.DirFS(workspacePath), pattern)
@@ -144,7 +144,7 @@ func simulateNewApproach(workspacePath string, serverName string) (int, time.Dur
144144 }
145145
146146 filesToOpen = append(filesToOpen, fullPath)
147−
147+
148148 // Limit the number of files per pattern
149149 if len(filesToOpen) >= 5 {
150150 break
@@ -156,14 +156,14 @@ func simulateNewApproach(workspacePath string, serverName string) (int, time.Dur
156156 batchSize := 3
157157 for i := 0; i < len(filesToOpen); i += batchSize {
158158 end := min(i+batchSize, len(filesToOpen))
159−
159+
160160 // Open batch of files
161161 for j := i; j < end; j++ {
162162 // Simulate file opening (1ms overhead)
163163 time.Sleep(1 * time.Millisecond)
164164 filesOpened++
165165 }
166−
166+
167167 // Only add delay between batches, not individual files
168168 if end < len(filesToOpen) {
169169 time.Sleep(50 * time.Millisecond)
@@ -205,11 +205,11 @@ func TestPerformanceComparison(t *testing.T) {
205205
206206 t.Logf("Old approach: %d files in %v", filesOpenedOld, oldDuration)
207207 t.Logf("New approach: %d files in %v", filesOpenedNew, newDuration)
208−
208+
209209 if newDuration > 0 && oldDuration > 0 {
210210 improvement := float64(oldDuration-newDuration) / float64(oldDuration) * 100
211211 t.Logf("Performance improvement: %.1f%%", improvement)
212−
212+
213213 if improvement <= 0 {
214214 t.Errorf("Expected performance improvement, but new approach was slower")
215215 }
@@ -224,4 +224,4 @@ func TestPerformanceComparison(t *testing.T) {
224224 if newDuration >= oldDuration {
225225 t.Errorf("New approach should be faster: old=%v, new=%v", oldDuration, newDuration)
226226 }
227−}
227+}