diff options
author | Rob Findley <rfindley@google.com> | 2020-09-11 14:23:34 -0400 |
---|---|---|
committer | Rob Findley <rfindley@google.com> | 2020-09-11 14:23:34 -0400 |
commit | f8b1c17aced24a1618c6984794be9770c5d260be (patch) | |
tree | 45af8d39b5c3d9f43d439ebec0a2ba42b49efe70 /src/go/types/self_test.go | |
parent | e5d91ab096a9ff9673311f1a7f3f860a7f9c2062 (diff) | |
parent | 07c1788357cfe6a4ee5f6f6a54d4fe9f579fa844 (diff) | |
download | go-f8b1c17aced24a1618c6984794be9770c5d260be.tar.gz go-f8b1c17aced24a1618c6984794be9770c5d260be.zip |
[dev.types] all: merge master into dev.typesdev.types
Change-Id: Ia6964cb4e09153c15cc9c5b441373d1b3cb8f757
Diffstat (limited to 'src/go/types/self_test.go')
-rw-r--r-- | src/go/types/self_test.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/go/types/self_test.go b/src/go/types/self_test.go index 10ad06fbca..04c9cd3458 100644 --- a/src/go/types/self_test.go +++ b/src/go/types/self_test.go @@ -47,8 +47,13 @@ func TestBenchmark(t *testing.T) { // We're not using testing's benchmarking mechanism directly // because we want custom output. - for _, p := range []string{"types", "constant", filepath.Join("internal", "gcimporter")} { - path := filepath.Join("..", p) + for _, p := range []string{ + "net/http", + "go/parser", + "go/constant", + filepath.Join("go", "internal", "gcimporter"), + } { + path := filepath.Join("..", "..", p) runbench(t, path, false) runbench(t, path, true) fmt.Println() @@ -64,8 +69,13 @@ func runbench(t *testing.T, path string, ignoreFuncBodies bool) { b := testing.Benchmark(func(b *testing.B) { for i := 0; i < b.N; i++ { - conf := Config{IgnoreFuncBodies: ignoreFuncBodies} - conf.Check(path, fset, files, nil) + conf := Config{ + IgnoreFuncBodies: ignoreFuncBodies, + Importer: importer.Default(), + } + if _, err := conf.Check(path, fset, files, nil); err != nil { + t.Fatal(err) + } } }) @@ -77,10 +87,9 @@ func runbench(t *testing.T, path string, ignoreFuncBodies bool) { }) d := time.Duration(b.NsPerOp()) - fmt.Printf( - "%s: %s for %d lines (%d lines/s), ignoreFuncBodies = %v\n", - filepath.Base(path), d, lines, int64(float64(lines)/d.Seconds()), ignoreFuncBodies, - ) + fmt.Printf("%s (ignoreFuncBodies = %v):\n", filepath.Base(path), ignoreFuncBodies) + fmt.Printf("\t%s for %d lines (%.0f lines/s)\n", d, lines, float64(lines)/d.Seconds()) + fmt.Printf("\t%s\n", b.MemString()) } func pkgFiles(fset *token.FileSet, path string) ([]*ast.File, error) { |