on main help sign in
fix: fmt files
commitaa0fb4c05437c3941fc860fe34e1eae920f7cd8a authorRaphael Amorim <rapha850@gmail.com> dateMon 16 Jun 2025, 12:11 (1 year ago) parentdb2170d
3 files changed+11−11
internal/llm/tools/shell/comparison_test.go+5−5 internal/llm/tools/shell/shell.go+3−3 internal/llm/tools/shell/shell_test.go+3−3
internal/llm/tools/shell/comparison_test.go+5−5
@@ -28,7 +28,7 @@ func TestShellPerformanceComparison(t *testing.T) {
2828 assert.Equal(t, 0, exitCode)
2929 assert.Contains(t, stdout, "hello")
3030 assert.Empty(t, stderr)
31−
31+
3232 t.Logf("Quick command took: %v", duration)
3333}
3434
@@ -48,13 +48,13 @@ func TestShellCPUUsageComparison(t *testing.T) {
4848 start := time.Now()
4949 _, stderr, exitCode, _, err := shell.Exec(context.Background(), "sleep 0.1", 1000)
5050 duration := time.Since(start)
51−
51+
5252 runtime.ReadMemStats(&m2)
5353
5454 require.NoError(t, err)
5555 assert.Equal(t, 0, exitCode)
5656 assert.Empty(t, stderr)
57−
57+
5858 memGrowth := m2.Alloc - m1.Alloc
5959 t.Logf("Sleep 0.1s command took: %v", duration)
6060 t.Logf("Memory growth during polling: %d bytes", memGrowth)
@@ -72,7 +72,7 @@ func BenchmarkShellPolling(b *testing.B) {
7272
7373 b.ResetTimer()
7474 b.ReportAllocs()
75−
75+
7676 for i := 0; i < b.N; i++ {
7777 // Use a short sleep to measure polling overhead
7878 _, _, exitCode, _, err := shell.Exec(context.Background(), "sleep 0.02", 500)
@@ -80,4 +80,4 @@ func BenchmarkShellPolling(b *testing.B) {
8080 b.Fatalf("Command failed: %v, exit code: %d", err, exitCode)
8181 }
8282 }
83−}
83+}
internal/llm/tools/shell/shell.go+3−3
@@ -192,10 +192,10 @@ echo $EXEC_EXIT_CODE > %s
192192 // Use exponential backoff polling
193193 pollInterval := 1 * time.Millisecond
194194 maxPollInterval := 100 * time.Millisecond
195−
195+
196196 ticker := time.NewTicker(pollInterval)
197197 defer ticker.Stop()
198−
198+
199199 for {
200200 select {
201201 case <-ctx.Done():
@@ -219,7 +219,7 @@ echo $EXEC_EXIT_CODE > %s
219219 return
220220 }
221221 }
222−
222+
223223 // Exponential backoff to reduce CPU usage for longer-running commands
224224 if pollInterval < maxPollInterval {
225225 pollInterval = time.Duration(float64(pollInterval) * 1.5)
internal/llm/tools/shell/shell_test.go+3−3
@@ -28,7 +28,7 @@ func TestShellPerformanceImprovement(t *testing.T) {
2828 assert.Equal(t, 0, exitCode)
2929 assert.Contains(t, stdout, "hello world")
3030 assert.Empty(t, stderr)
31−
31+
3232 // Quick commands should complete very fast with our exponential backoff
3333 assert.Less(t, duration, 50*time.Millisecond, "Quick command should complete fast with exponential backoff")
3434}
@@ -44,11 +44,11 @@ func BenchmarkShellQuickCommands(b *testing.B) {
4444
4545 b.ResetTimer()
4646 b.ReportAllocs()
47−
47+
4848 for i := 0; i < b.N; i++ {
4949 _, _, exitCode, _, err := shell.Exec(context.Background(), "echo test", 0)
5050 if err != nil || exitCode != 0 {
5151 b.Fatalf("Command failed: %v, exit code: %d", err, exitCode)
5252 }
5353 }
54−}
54+}