1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:38:33 -06:00
Commit Graph

2 Commits

Author SHA1 Message Date
Lucas Bremgartner
0110d43865 cover: error on negative numbers in profiles
CL 179377 introduced an optimized parser for coverage profiles.
The parser replaces the following regex:
^(.+):([0-9]+)\.([0-9]+),([0-9]+)\.([0-9]+) ([0-9]+) ([0-9]+)$

With this regex, negative numbers in the coverage profiles resulted
in parsing errors. With the new parser in place, this is no longer
the case. This commit restores the old behavior.

Change-Id: Iaa72035f1f587ed186eaf5a84b209df88e67fb57
GitHub-Last-Rev: 07470fba9d587e6d3f383409fc8cf52bb882a984
GitHub-Pull-Request: golang/tools#195
Reviewed-on: https://go-review.googlesource.com/c/tools/+/213357
Reviewed-by: Katharine Berry <ktbry@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-15 21:23:19 +00:00
Katharine Berry
7defa796fe cover: significantly improve the speed of cover.ParseProfiles
ParseProfiles currently uses a regex to parse each line. This is not
very fast, and can lead to ParseProfiles being excessively slow on
certain pathological inputs.

This change substantially improves the performance by parsing manually
instead. On an input of about 3 GB of data containing about 36 million
lines, the time spent in ParseProfiles drops from 72 seconds to 11
seconds, with actual string parsing time dropping from 61 seconds to 2
seconds.

Since this change completely changes the parsing, it also adds some
tests for ParseProfiles to help ensure the new parsing is correct.

A benchmark for parseLine is also included. Here is a comparison of the old
regex implementation versus the new manual one:

name          old time/op    new time/op      delta
ParseLine-12    2.43µs ± 2%      0.05µs ± 8%    -97.98%  (p=0.000 n=10+9)

name          old speed      new speed        delta
ParseLine-12  42.5MB/s ± 2%  2103.2MB/s ± 7%  +4853.14%  (p=0.000 n=10+9)

Fixes golang/go#32211

Change-Id: If8f91ecbda776c08243de4e423de4eea55f0082b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/179377
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-24 07:44:52 +00:00