on main help sign in
chore: fix broken performance tests:
20a1704Andrey Nering
internal/llm/tools/shell/comparison_test.go−29
@@ -3,7 +3,6 @@ package shell
3import (
3import (
4 "context"
4 "context"
5 "os"
5 "os"
6− "runtime"
7 "testing"
6 "testing"
8 "time"
7 "time"
9
8
@@ -32,34 +31,6 @@ func TestShellPerformanceComparison(t *testing.T) {
32 t.Logf("Quick command took: %v", duration)
31 t.Logf("Quick command took: %v", duration)
33}
32}
34
33
35−func TestShellCPUUsageComparison(t *testing.T) {
36− tmpDir, err := os.MkdirTemp("", "shell-test")
37− require.NoError(t, err)
38− defer os.RemoveAll(tmpDir)
39−
40− shell := GetPersistentShell(tmpDir)
41− defer shell.Close()
42−
43− // Measure CPU and memory usage during a longer command
44− var m1, m2 runtime.MemStats
45− runtime.GC()
46− runtime.ReadMemStats(&m1)
47−
48− start := time.Now()
49− _, stderr, exitCode, _, err := shell.Exec(context.Background(), "sleep 0.1", 1000)
50− duration := time.Since(start)
51−
52− runtime.ReadMemStats(&m2)
53−
54− require.NoError(t, err)
55− assert.Equal(t, 0, exitCode)
56− assert.Empty(t, stderr)
57−
58− memGrowth := m2.Alloc - m1.Alloc
59− t.Logf("Sleep 0.1s command took: %v", duration)
60− t.Logf("Memory growth during polling: %d bytes", memGrowth)
61− t.Logf("GC cycles during test: %d", m2.NumGC-m1.NumGC)
62−}
63
34
64// Benchmark CPU usage during polling
35// Benchmark CPU usage during polling
65func BenchmarkShellPolling(b *testing.B) {
36func BenchmarkShellPolling(b *testing.B) {
internal/llm/tools/shell/shell_test.go−25
@@ -4,35 +4,10 @@ import (
4 "context"
4 "context"
5 "os"
5 "os"
6 "testing"
6 "testing"
7− "time"
8
7
9− "github.com/stretchr/testify/assert"
10 "github.com/stretchr/testify/require"
8 "github.com/stretchr/testify/require"
11)
9)
12
10
13−func TestShellPerformanceImprovement(t *testing.T) {
14− // Create a temporary directory for the shell
15− tmpDir, err := os.MkdirTemp("", "shell-test")
16− require.NoError(t, err)
17− defer os.RemoveAll(tmpDir)
18−
19− shell := GetPersistentShell(tmpDir)
20− defer shell.Close()
21−
22− // Test that quick commands complete fast
23− start := time.Now()
24− stdout, stderr, exitCode, _, err := shell.Exec(context.Background(), "echo 'hello world'", 0)
25− duration := time.Since(start)
26−
27− require.NoError(t, err)
28− assert.Equal(t, 0, exitCode)
29− assert.Contains(t, stdout, "hello world")
30− assert.Empty(t, stderr)
31−
32− // Quick commands should complete very fast with our exponential backoff
33− assert.Less(t, duration, 50*time.Millisecond, "Quick command should complete fast with exponential backoff")
34−}
35−
36// Benchmark to measure CPU efficiency
11// Benchmark to measure CPU efficiency
37func BenchmarkShellQuickCommands(b *testing.B) {
12func BenchmarkShellQuickCommands(b *testing.B) {
38 tmpDir, err := os.MkdirTemp("", "shell-bench")
13 tmpDir, err := os.MkdirTemp("", "shell-bench")