Support per-benchmark custom context in JSON output#2250
Closed
devtejasx wants to merge 1 commit into
Closed
Conversation
Add Benchmark::AddCustomContext(key, value) to attach string key-value pairs to a benchmark at registration time. The pairs are reported with every result of that benchmark (including aggregates) as a custom_context object in the JSON output, complementing the existing run-wide benchmark::AddCustomContext() which only goes into the top-level context. This allows tagging generated benchmark variants with structured metadata instead of encoding it into the benchmark name and parsing it back out of reports. Fixes google#1890
dmah42
reviewed
Jul 15, 2026
Member
|
can you explain the use-case more clearly? the benchmark already supports plenty of ways to change the name, or add parameters... why do we need custom context? |
Contributor
Author
|
Fair point for the metadata-tagging case I had in mind, a naming/ArgNames convention plus the existing run-wide context is enough, and it's not worth adding new API surface for. I'll close this. Thanks for taking a look. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Benchmark::AddCustomContext(key, value) to attach string key-value pairs to a benchmark at registration time. The pairs are reported with every result of that benchmark (including aggregates) as a custom_context object in the JSON output, complementing the existing run-wide benchmark::AddCustomContext() which only goes into the top-level context. This allows tagging generated benchmark variants with structured metadata instead of encoding it into the benchmark name and parsing it back out of reports.
Fixes #1890