Skip to content

Emit memory_iterations in JSONReporter - #2380

Open
mhansen wants to merge 1 commit into
google:mainfrom
mhansen:json_iters
Open

mhansen wants to merge 1 commit into
google:mainfrom
mhansen:json_iters

Conversation

@mhansen

@mhansen mhansen commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Background: I have a tool consuming this, and I'd like to know how many iterations, so I can divide total bytes by iterations.

MemoryManager::Result records total_allocated_bytes and net_heap_growth as totals across memory_iterations iterations, while JSONReporter only emitted allocs_per_iter and those raw totals without memory_iterations, preventing consumers from computing per-iteration byte counts.

Emit memory_iterations in JSONReporter whenever a memory run occurs, and update memory_manager_test and memory_results_gtest.

AI-assisted: this change was written with the help of an AI coding tool.

`MemoryManager::Result` records `total_allocated_bytes` and `net_heap_growth`
as totals across `memory_iterations` iterations, while `JSONReporter` only
emitted `allocs_per_iter` and those raw totals without `memory_iterations`,
preventing consumers from computing per-iteration byte counts.

Emit `memory_iterations` in `JSONReporter` whenever a memory run occurs, and
update `memory_manager_test` and `memory_results_gtest`.

AI-assisted: this change was written with the help of an AI coding tool.

@LebedevRI LebedevRI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I hadn't realised we weren't doing this already.

}
}

TEST_F(MemoryResultsTest, JSONReporterIncludesMemoryMetrics) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't have much gtest's, i'm a bit unconvinced if this should be/needs a gtest.
@dmah42 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

up to you - happy to remove if you prefer. I would personally prefer to have some kind of test that will show up if this ever breaks as i'm about to start relying on it :-)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We generally prefer end-to-end tests like the change in that other test file ^.

@mhansen mhansen Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right - I saw the other file, and I thought, I'd like to know that integer is the right number (not just 'any integer')- felt a bit less than the ideal amount of assurance I'd be after to just assert that it's an int. Again, happy to revert this file if preferred, just explaining where i was coming from. Certainly I use tests a lot to gain assurance that my AI-driven code is actually doing the right thing - I probably add more tests than most people.

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.

i'm quite happy to have gtests for low level behaviour checks. the end to end tests are good for checking the actual output matches expectations, but gtests are quick and more direct. in general i wish we had more gtests and relied less on the actual output, but the output is ultimately what folks care about not regressing on.

This branch has not been deployed

No deployments
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.

3 participants