-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate implementation of _process_totals
#523
Conversation
In particular, this unifies the duplicated implementations of these methods across `Filtered/ReportFile`. The new method also spells out a "very concise, but also unreadable" implementation that sums up the cyclomatic complexity (something I would like to remove completely eventually). This is now more readable and understandable, but more importantly, it only iterates over the `lines` *once*, instead of twice as the previous implementation did. Along with avoiding a bunch of intermediate list allocations that the `FilteredReportFile` implementation did, this should yield quite a good speedup.
CodSpeed Performance ReportMerging #523 will create unknown performance changesComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left some questions
shared/reports/totals.py
Outdated
complexity_total = 0 | ||
|
||
for line in lines: | ||
match line_type(line.coverage): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] line_type
and line.type
(below) are confusing... Maybe we can rename line_type(
something like line_coverage_type
or line_coverage
If they are the same thing, why can't we match the block below in this match
?
if line.type == "b":
branches += 1
elif line.type == "m":
methods += 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the imports for the line_type
and LineType
above to make the distinction a little clearer.
elif line.type == "m": | ||
methods += 1 | ||
|
||
if line.messages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A completely unused thing :-D Otherwise I don’t think anyone really knows.
In particular, this unifies the duplicated implementations of these methods across
Filtered/ReportFile
.The new method also spells out a "very concise, but also unreadable" implementation that sums up the cyclomatic complexity (something I would like to remove completely eventually). This is now more readable and understandable, but more importantly, it only iterates over the
lines
once, instead of twice as the previous implementation did. Along with avoiding a bunch of intermediate list allocations that theFilteredReportFile
implementation did, this should yield quite a good speedup.I get the following benchmarks results now locally (as sadly, benchmarks are not yet fully working in CI):
Comparing this with the numbers in #512, we can see that the
process_totals
benchmark got a speedup of 2x (-50ms), and thefiltering
benchmark as well got sped up by -50ms.