Skip to content

test: fix BenchmarkNova clone setup#83

Open
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:test/benchmark-nova-issue-16-v2
Open

test: fix BenchmarkNova clone setup#83
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:test/benchmark-nova-issue-16-v2

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 30, 2026

Fixes #16

Made with Cursor

Clone nova once over HTTPS, use b.Cleanup for teardown, and measure only
WalkDir in the benchmark loop.

Fixes dolph#16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69164dea8f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread find_replace_test.go
b.StopTimer()
d := cloneRepoToBenchDir(b, repoURL)
fr := findReplace{find: RandomString(2), replace: RandomString(2)}
b.ResetTimer()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restart the benchmark timer before walking

After b.StopTimer(), b.ResetTimer() only clears counters; the Go testing.B.ResetTimer docs state it does not affect whether the timer is running. As a result, every fr.WalkDir(d) call runs while the benchmark timer is still stopped, so go test -bench reports invalid near-zero timings. Call b.StartTimer() before the loop, or avoid stopping the timer and just reset it after setup.

Useful? React with 👍 / 👎.

Comment thread find_replace_test.go
const repoURL = "https://github.com/openstack/nova.git"

b.StopTimer()
d := cloneRepoToBenchDir(b, repoURL)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recreate the checkout for each benchmark iteration

Because the checkout is cloned only once outside the b.N loop, the first WalkDir mutates that tree by rewriting contents and renaming paths; when b.N > 1, later iterations walk an already-transformed repository and no longer measure the same find/replace workload. This amortizes a single real replacement run across many mostly no-op walks, so the benchmark result is misleading even after the timer is restarted.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BenchmarkNova depends on cloning openstack/nova over the network and uses an SSH URL

1 participant