@@ -19,7 +19,7 @@ func createTestWorkspace(tb testing.TB) string {
19 // Create test files for Go project
19 // Create test files for Go project
20 testFiles := []string{
20 testFiles := []string{
22− "go.sum",
22+ "go.sum",
23 "main.go",
23 "main.go",
24 "src/lib.go",
24 "src/lib.go",
25 "src/utils.go",
25 "src/utils.go",
@@ -38,11 +38,11 @@ func createTestWorkspace(tb testing.TB) string {
38 for _, file := range testFiles {
38 for _, file := range testFiles {
39 fullPath := filepath.Join(tmpDir, file)
39 fullPath := filepath.Join(tmpDir, file)
40 dir := filepath.Dir(fullPath)
40 dir := filepath.Dir(fullPath)
42 if err := os.MkdirAll(dir, 0755); err != nil {
42 if err := os.MkdirAll(dir, 0755); err != nil {
43 tb.Fatal(err)
43 tb.Fatal(err)
46 if err := os.WriteFile(fullPath, []byte("// test content"), 0644); err != nil {
46 if err := os.WriteFile(fullPath, []byte("// test content"), 0644); err != nil {
47 tb.Fatal(err)
47 tb.Fatal(err)
@@ -128,7 +128,7 @@ func simulateNewApproach(workspacePath string, serverName string) (int, time.Dur
129 // NEW APPROACH: Collect all files first
129 // NEW APPROACH: Collect all files first
130 var filesToOpen []string
130 var filesToOpen []string
132 // For each pattern, find matching files
132 // For each pattern, find matching files
133 for _, pattern := range patterns {
133 for _, pattern := range patterns {
134 matches, err := doublestar.Glob(os.DirFS(workspacePath), pattern)
134 matches, err := doublestar.Glob(os.DirFS(workspacePath), pattern)
@@ -144,7 +144,7 @@ func simulateNewApproach(workspacePath string, serverName string) (int, time.Dur
146 filesToOpen = append(filesToOpen, fullPath)
146 filesToOpen = append(filesToOpen, fullPath)
148 // Limit the number of files per pattern
148 // Limit the number of files per pattern
149 if len(filesToOpen) >= 5 {
149 if len(filesToOpen) >= 5 {
@@ -156,14 +156,14 @@ func simulateNewApproach(workspacePath string, serverName string) (int, time.Dur
156 batchSize := 3
156 batchSize := 3
157 for i := 0; i < len(filesToOpen); i += batchSize {
157 for i := 0; i < len(filesToOpen); i += batchSize {
158 end := min(i+batchSize, len(filesToOpen))
158 end := min(i+batchSize, len(filesToOpen))
160 // Open batch of files
160 // Open batch of files
161 for j := i; j < end; j++ {
161 for j := i; j < end; j++ {
162 // Simulate file opening (1ms overhead)
162 // Simulate file opening (1ms overhead)
163 time.Sleep(1 * time.Millisecond)
163 time.Sleep(1 * time.Millisecond)
164 filesOpened++
164 filesOpened++
167 // Only add delay between batches, not individual files
167 // Only add delay between batches, not individual files
168 if end < len(filesToOpen) {
168 if end < len(filesToOpen) {
169 time.Sleep(50 * time.Millisecond)
169 time.Sleep(50 * time.Millisecond)
@@ -205,11 +205,11 @@ func TestPerformanceComparison(t *testing.T) {
206 t.Logf("Old approach: %d files in %v", filesOpenedOld, oldDuration)
206 t.Logf("Old approach: %d files in %v", filesOpenedOld, oldDuration)
207 t.Logf("New approach: %d files in %v", filesOpenedNew, newDuration)
207 t.Logf("New approach: %d files in %v", filesOpenedNew, newDuration)
209 if newDuration > 0 && oldDuration > 0 {
209 if newDuration > 0 && oldDuration > 0 {
210 improvement := float64(oldDuration-newDuration) / float64(oldDuration) * 100
210 improvement := float64(oldDuration-newDuration) / float64(oldDuration) * 100
211 t.Logf("Performance improvement: %.1f%%", improvement)
211 t.Logf("Performance improvement: %.1f%%", improvement)
213 if improvement <= 0 {
213 if improvement <= 0 {
214 t.Errorf("Expected performance improvement, but new approach was slower")
214 t.Errorf("Expected performance improvement, but new approach was slower")
@@ -224,4 +224,4 @@ func TestPerformanceComparison(t *testing.T) {
224 if newDuration >= oldDuration {
224 if newDuration >= oldDuration {
225 t.Errorf("New approach should be faster: old=%v, new=%v", oldDuration, newDuration)
225 t.Errorf("New approach should be faster: old=%v, new=%v", oldDuration, newDuration)