diff options
author | Robert Griesemer <gri@golang.org> | 2011-05-02 09:17:46 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2011-05-02 09:17:46 -0700 |
commit | 94939ebf505efec6f0def2e879354abccecdc511 (patch) | |
tree | bfd0135ad0f4cec72074e5023f335af6ef49b5c4 /src/pkg/go/printer/testdata | |
parent | ed3eeb072f22754a3bb36b4b596e9692d28e549a (diff) | |
download | go-94939ebf505efec6f0def2e879354abccecdc511.tar.gz |
go/token: faster FileSet.Position implementation
- added a cache for last file looked up: avoids binary
search if the file matches
- don't look up extra line info if not present
(it is almost never present)
- inline one critical binary search call (inlining
provides almost 30% improvement in this case)
Together, these changes make the go/printer benchmark
more than twice as fast (53% improvement). gofmt also
sped up by about the same amount.
Also: removed an unused internal field from FileSet.
Measurements (always best of 5 runs):
* original:
printer.BenchmarkPrint 5 238354200 ns/op (100%)
* using last file cache:
printer.BenchmarkPrint 10 201796600 ns/op (85%)
* avoiding lookup of extra line info:
printer.BenchmarkPrint 10 157072700 ns/op (66%)
* inlining a critical binary search call:
printer.BenchmarkPrint 10 111523500 ns/op (47%)
gofmt (always best of 3 runs):
* before:
time gofmt -l src misc
real 0m33.316s
user 0m31.298s
sys 0m0.319s
* after:
time gofmt -l src misc
real 0m15.889s
user 0m14.596s
sys 0m0.224s
R=r, dfc, bradfitz, rsc1
CC=golang-dev
http://codereview.appspot.com/4433086
Diffstat (limited to 'src/pkg/go/printer/testdata')
0 files changed, 0 insertions, 0 deletions