-
Notifications
You must be signed in to change notification settings - Fork 78
Lcov: benchmark & performance work #270
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
Conversation
Motivated as useful by #264
While investigating #264, this popped out as low-hanging fruit: calling `CalcLineCounts` on a source file repeatedly is just wasted work. In fact, I don't think the formatter needs to call this method at all: it's already called by `Reporter.AddSourceFile`. (It's also called by `SourceFile.MarshalJSON`, so I think there's more inefficiency there to root out, but we can at least get down to calling it 2 times rather than `LOC + 2` times.)
Similar to the previous commit, looking for perf wins this is another bit of low hanging fruit: `HEAD` should not change while the test reporter is running. (If it did, I don't think we can even guarantee any kind of sensible results.)
fb757b9
to
976c0ca
Compare
@@ -64,7 +65,6 @@ func (r Formatter) Format() (formatters.Report, error) { | |||
} | |||
for ln-curLine >= 1 { | |||
sf.Coverage = append(sf.Coverage, formatters.NullInt{}) | |||
sf.CalcLineCounts() |
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.
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.
good catcht! looks good to me
var sf formatters.SourceFile | ||
curLine := 1 | ||
|
||
for _, line := range bytes.Split(b, []byte("\n")) { | ||
if bytes.HasPrefix(line, []byte("SF:")) { | ||
name := string(bytes.TrimSpace(bytes.TrimPrefix(line, []byte("SF:")))) | ||
var gitHead, _ = env.GetHead() |
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.
nice! this was a super oversight on my part 🤦♀️
i think we can probably improve this on other formatters as well.
@wfleming you can run |
@ale7714 I haven't revisited this, but It think the changes as-is are worth shipping out for some improvements. Can you reviews this when you're back next week? |
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.
Changes LGTM!
Changes made while investigating #264, please see commits for details.