Skip to content

Commit b95a0d5

Browse files
committed
update run instrucs and seedshadowbranch
1 parent 1a95bc3 commit b95a0d5

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

cmd/entire/cli/benchutil/benchutil.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ type BenchRepo struct {
4444

4545
// WorktreeID is the worktree identifier (empty for main worktree).
4646
WorktreeID string
47+
48+
// Strategy is the strategy name used in .entire/settings.json.
49+
Strategy string
4750
}
4851

4952
// RepoOpts configures how NewBenchRepo creates the test repository.
@@ -167,6 +170,7 @@ func NewBenchRepo(b *testing.B, opts RepoOpts) *BenchRepo {
167170
Repo: repo,
168171
Store: checkpoint.NewGitStore(repo),
169172
HeadHash: headHash.String(),
173+
Strategy: opts.Strategy,
170174
}
171175

172176
// Determine worktree ID
@@ -344,9 +348,17 @@ func (br *BenchRepo) WriteTranscriptFile(b *testing.B, sessionID string, data []
344348
// SeedShadowBranch creates N checkpoint commits on the shadow branch
345349
// for the current HEAD. This simulates a session that already has
346350
// prior checkpoints saved.
351+
//
352+
// Temporarily changes cwd to br.Dir because WriteTemporary uses
353+
// paths.RepoRoot() which depends on os.Getwd().
347354
func (br *BenchRepo) SeedShadowBranch(b *testing.B, sessionID string, checkpointCount int, filesPerCheckpoint int) {
348355
b.Helper()
349356

357+
// WriteTemporary internally calls paths.RepoRoot() which uses os.Getwd().
358+
// Switch cwd so it resolves to the bench repo.
359+
b.Chdir(br.Dir)
360+
paths.ClearRepoRootCache()
361+
350362
for i := range checkpointCount {
351363
var modified []string
352364
for j := range filesPerCheckpoint {
@@ -411,7 +423,7 @@ func (br *BenchRepo) SeedMetadataBranch(b *testing.B, checkpointCount int) {
411423
err = br.Store.WriteCommitted(context.Background(), checkpoint.WriteCommittedOptions{
412424
CheckpointID: cpID,
413425
SessionID: sessionID,
414-
Strategy: "manual-commit",
426+
Strategy: br.Strategy,
415427
Transcript: transcript,
416428
Prompts: []string{fmt.Sprintf("Implement feature %d", i)},
417429
FilesTouched: files,

cmd/entire/cli/benchutil/benchutil_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ func BenchmarkNewBenchRepo_Large(b *testing.B) {
2222
}
2323

2424
func BenchmarkSeedShadowBranch(b *testing.B) {
25-
repo := NewBenchRepo(b, RepoOpts{FileCount: 10})
26-
sessionID := repo.CreateSessionState(b, SessionOpts{})
27-
28-
b.ResetTimer()
2925
for b.Loop() {
30-
// Each iteration seeds a fresh shadow branch
31-
// (will append to existing, but that's fine for benchmarking)
26+
b.StopTimer()
27+
repo := NewBenchRepo(b, RepoOpts{FileCount: 10})
28+
sessionID := repo.CreateSessionState(b, SessionOpts{})
29+
b.StartTimer()
30+
3231
repo.SeedShadowBranch(b, sessionID, 5, 3)
3332
}
3433
}
3534

3635
func BenchmarkSeedMetadataBranch(b *testing.B) {
37-
repo := NewBenchRepo(b, RepoOpts{FileCount: 10})
38-
39-
b.ResetTimer()
4036
for b.Loop() {
37+
b.StopTimer()
38+
repo := NewBenchRepo(b, RepoOpts{FileCount: 10})
39+
b.StartTimer()
40+
4141
repo.SeedMetadataBranch(b, 10)
4242
}
4343
}

mise.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ run = "go test -bench=. -benchmem -run='^$' -timeout=10m ./..."
101101

102102
[tasks."bench:cpu"]
103103
description = "Run benchmarks with CPU profile"
104-
run = "go test -bench=. -benchmem -run='^$' -cpuprofile=cpu.prof -timeout=10m ./... && echo 'Profile saved to cpu.prof. View with: go tool pprof -http=:8080 cpu.prof'"
104+
run = "go test -bench=. -benchmem -run='^$' -cpuprofile=cpu.prof -timeout=10m ./... && echo 'CPU Profiles saved as cpu.prof in each benchmarked package directory. List them with : find. -name cpu.prof -print. View one with: go tool pprof -http=:8080 /path/to/.cpu.prof'"
105105

106106
[tasks."bench:mem"]
107107
description = "Run benchmarks with memory profile"
108-
run = "go test -bench=. -benchmem -run='^$' -memprofile=mem.prof -timeout=10m ./... && echo 'Profile saved to mem.prof. View with: go tool pprof -http=:8080 mem.prof'"
108+
run = "go test -bench=. -benchmem -run='^$' -memprofile=mem.prof -timeout=10m ./... && echo 'Memory profiles saved as mem.prof in each benchmarked package directory. List with them: find . -name mem.prof -print. View one with: go tool pprof -http=:8080 /path/to/mem.prof'"
109109

110110
[tasks."test:e2e"]
111111
description = "Run E2E tests with real agent calls (requires claude CLI)"

0 commit comments

Comments
 (0)