Skip to content

Report the complexity aggregates in the family's time unit - #2294

Open
lenamonj wants to merge 6 commits into
google:mainfrom
lenamonj:complexity-time-unit
Open

Report the complexity aggregates in the family's time unit#2294
lenamonj wants to merge 6 commits into
google:mainfrom
lenamonj:complexity-time-unit

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 7, 2026

Copy link
Copy Markdown

ComputeBigO never set big_o.time_unit, so the BigO row kept the Run() default of nanoseconds and its coefficient was rendered in ns whatever unit the family declared. It now carries the family's unit, as the RMS row already did.

The new BM_Complexity_O_N_ms family declares milliseconds: on main its BigO row reports "time_unit": "ns". The test fails on main and passes here.

ComputeBigO left big_o.time_unit at the Run() default, so the BigO row was rendered in nanoseconds whatever unit the family declared; CSVReporter rendered the RMS row from the raw, pre-divided field, so it was smaller by the unit multiplier. Both now go through the family unit and the GetAdjusted*Time() accessors, with a millisecond family in complexity_test.cc that fails on main for both.
Comment thread src/complexity.cc Outdated
big_o.cpu_accumulated_time = result_cpu.coef;
big_o.report_big_o = true;
big_o.complexity = result_cpu.complexity;
// The coefficient is a time; reporters render it in the family's unit.

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.

unnecessary comment

Comment thread test/complexity_test.cc Outdated
const std::string& rms_test_name,
const std::string& big_o, int family_index) {
const std::string& big_o, int family_index,
const std::string& time_unit = "ns",

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.

why are there defaults here?

@lenamonj

lenamonj commented Sep 7, 2026

Copy link
Copy Markdown
Author

Removed the comment and the defaults; each family passes its unit and CSV pattern explicitly.

@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.

CSV reporter is deprecated and should not be used.

The CSV reporter is deprecated, so its RMS row is left as it is and the
test keeps the pattern it had.
@lenamonj

lenamonj commented Sep 7, 2026

Copy link
Copy Markdown
Author

Dropped the CSV reporter change and its test pattern; the PR is now the one-line time_unit fix with the JSON check.

Comment thread test/complexity_test.cc

@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.

Ah, hmm, when initially reading the change, somehow i missed that it was also 'fixing' JSON.
I thought it was only making CSV do the same as JSON reporter.

After sleeping on this, i do think this makes sense.

I do have a suggestion though: is there a test that breaks
if you intentionally scale the value of the "bigo" field in JSON reporter
by x1000? There should be one, we should have a test
to ensure that the reported bigo really does have the correct magnitude
as implied by the unit.

@LebedevRI LebedevRI self-assigned this Sep 11, 2026
Until now, scaling the JSON BigO coefficients by 1000 left every test
passing. Under manual time the millisecond family's real coefficient is
about 1.0004e-03, so its BigO row now has to match 1\.[0-9]+e-03, and
that scaling fails it. The skew comment is corrected: of the family's
sizes, 1024 to 65536, only 2048 has bit 11 set.
@lenamonj

Copy link
Copy Markdown
Author

There is now: scaling both coefficients by 1000 in json_reporter.cc fails complexity_benchmark, because the millisecond family's real_coefficient, about 1.0004e-03 ms per N, has to match 1\.[0-9]+e-03; at 6169934 all 87 tests passed under that scaling. cpu_coefficient stays %float because it is measured CPU time that varies from run to run.

@LebedevRI
LebedevRI self-requested a review September 13, 2026 18:06
@LebedevRI
LebedevRI requested a review from dmah42 September 13, 2026 19:08
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