1package shell
2
3import (
4 "context"
5 "os"
6 "testing"
7
8 "github.com/stretchr/testify/require"
9)
10
11// Benchmark to measure CPU efficiency
12func BenchmarkShellQuickCommands(b *testing.B) {
13 tmpDir, err := os.MkdirTemp("", "shell-bench")
14 require.NoError(b, err)
15 defer os.RemoveAll(tmpDir)
16
17 shell := GetPersistentShell(tmpDir)
18 defer shell.Close()
19
20 b.ResetTimer()
21 b.ReportAllocs()
22
23 for i := 0; i < b.N; i++ {
24 _, _, exitCode, _, err := shell.Exec(context.Background(), "echo test", 0)
25 if err != nil || exitCode != 0 {
26 b.Fatalf("Command failed: %v, exit code: %d", err, exitCode)
27 }
28 }
29}