Skip to content

Make BenchId Movable and Copyable#6491

Open
moseschmiedel wants to merge 3 commits into
modular:mainfrom
moseschmiedel:copyable-benchid
Open

Make BenchId Movable and Copyable#6491
moseschmiedel wants to merge 3 commits into
modular:mainfrom
moseschmiedel:copyable-benchid

Conversation

@moseschmiedel
Copy link
Copy Markdown

Summary

BenchId now implements the Movable and Copyable trait.
Closes #6490

Testing

Ran the benchmark tests via ./bazelw test ////mojo/stdlib/benchmarks/...

Checklist

  • PR is small and focused — consider splitting larger changes into a
    sequence of smaller PRs
  • I ran ./bazelw run format to format my changes
  • I added or updated tests to cover my changes
  • If AI tools assisted with this contribution, I have included an
    Assisted-by: trailer in my commit message or this PR description
    (see AI Tool Use Policy)

Copilot AI review requested due to automatic review settings May 4, 2026 09:22
@moseschmiedel moseschmiedel requested a review from a team as a code owner May 4, 2026 09:22
@github-actions github-actions Bot added mojo-stdlib Tag for issues related to standard library waiting-on-review labels May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@moseschmiedel
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the std.benchmark API so that BenchId can be freely stored and passed around in value containers (e.g., List, Tuple) by making it conform to Movable and Copyable, addressing the ergonomics issue raised in #6490.

Changes:

  • Make BenchId implement Copyable, ImplicitlyCopyable, and Movable to support use in common value-based collections/aggregates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@JoeLoser JoeLoser left a comment

Choose a reason for hiding this comment

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

Hi there! 👋

Thanks for the contribution. I left a few comments to check out before we merge this.

Comment thread mojo/stdlib/std/benchmark/bencher.mojo Outdated

@fieldwise_init
struct BenchId:
struct BenchId(Copyable, ImplicitlyCopyable, Movable):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question Do we need the ImplicitlyCopyable or is the explicit copying just fine?

Do you mind adding a test case for this? Something like constructing a List[BenchId] and show copying them works fine.

@moseschmiedel
Copy link
Copy Markdown
Author

While adding the test case I also thought about adding Equatable and Hashable. It would allow us to use the BenchId as a Dict KeyElement which for an identifier would make sense in my opinion. What do you think @JoeLoser ?

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

Labels

mojo-stdlib Tag for issues related to standard library waiting-on-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Make BenchId Copyable or at least Movable

3 participants