diff options
author | Robert Griesemer <gri@golang.org> | 2017-03-21 22:23:15 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2017-03-22 22:37:08 +0000 |
commit | b5f81eae17b68c9a34d23dcf4669e3d879781b35 (patch) | |
tree | 3a8827c045d3d219bfd306318429d834ca575887 /src/cmd/compile/internal/syntax/parser_test.go | |
parent | e0329248d5cda9a6a6c1492a2fdeeacd982afc9c (diff) | |
download | go-b5f81eae17b68c9a34d23dcf4669e3d879781b35.tar.gz go-b5f81eae17b68c9a34d23dcf4669e3d879781b35.zip |
cmd/compile/internal/syntax: replace inlined statement lists with syntax.BlockStmt
This simplifies the code and removes a premature optimization.
It increases the amount of allocated syntax.Node space by ~0.4%
for parsing all of std lib, which is negligible.
Before the change (best of 5 runs):
$ go test -run StdLib -fast
parsed 1517022 lines (3394 files) in 793.487886ms (1911840 lines/s)
allocated 387.086Mb (267B/line, 487.828Mb/s)
After the change (best of 5 runs):
$ go test -run StdLib -fast
parsed 1516911 lines (3392 files) in 805.028655ms (1884294 lines/s)
allocated 388.466Mb (268B/line, 482.549Mb/s)
Change-Id: Id19d6210fdc62393862ba3b04913352d95c599be
Reviewed-on: https://go-review.googlesource.com/38439
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/parser_test.go')
-rw-r--r-- | src/cmd/compile/internal/syntax/parser_test.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/syntax/parser_test.go b/src/cmd/compile/internal/syntax/parser_test.go index 06c74cbfba..4c317dab60 100644 --- a/src/cmd/compile/internal/syntax/parser_test.go +++ b/src/cmd/compile/internal/syntax/parser_test.go @@ -23,10 +23,7 @@ var src_ = flag.String("src", "parser.go", "source file to parse") var verify = flag.Bool("verify", false, "verify idempotent printing") func TestParse(t *testing.T) { - _, err := ParseFile(*src_, nil, nil, 0) - if err != nil { - t.Fatal(err) - } + ParseFile(*src_, func(err error) { t.Error(err) }, nil, 0) } func TestStdLib(t *testing.T) { @@ -81,7 +78,7 @@ func TestStdLib(t *testing.T) { dm := float64(m2.TotalAlloc-m1.TotalAlloc) / 1e6 fmt.Printf("parsed %d lines (%d files) in %v (%d lines/s)\n", lines, count, dt, int64(float64(lines)/dt.Seconds())) - fmt.Printf("allocated %.3fMb (%dB/line, %.3fMb/s)\n", dm, uint64(dm*(1<<20)/float64(lines)), dm/dt.Seconds()) + fmt.Printf("allocated %.3fMb (%.3fMb/s)\n", dm, dm/dt.Seconds()) } func walkDirs(t *testing.T, dir string, action func(string)) { |