Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(624)

Delta Between Two Patch Sets: ssa/stdlib_test.go

Issue 37970043: code review 37970043: go.tools/ssa: move AllFunctions to ssautil subpackage (Closed)
Left Patch Set: Created 10 years, 3 months ago
Right Patch Set: diff -r b522e6a8d9b8 https://code.google.com/p/go.tools Created 10 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « ssa/ssautil/visit.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package ssa_test 5 package ssa_test
6 6
7 // This file runs the SSA builder in sanity-checking mode on all 7 // This file runs the SSA builder in sanity-checking mode on all
8 // packages beneath $GOROOT and prints some summary information. 8 // packages beneath $GOROOT and prints some summary information.
9 // 9 //
10 // Run test with GOMAXPROCS=8. 10 // Run test with GOMAXPROCS=8.
11 11
12 import ( 12 import (
13 "go/build" 13 "go/build"
14 "go/token" 14 "go/token"
15 "os" 15 "os"
16 "path/filepath" 16 "path/filepath"
17 "runtime" 17 "runtime"
18 "strings" 18 "strings"
19 "testing" 19 "testing"
20 "time" 20 "time"
21 21
22 "code.google.com/p/go.tools/importer" 22 "code.google.com/p/go.tools/importer"
23 "code.google.com/p/go.tools/ssa" 23 "code.google.com/p/go.tools/ssa"
24 "code.google.com/p/go.tools/ssa/ssautil"
24 ) 25 )
25 26
26 const debugMode = false 27 const debugMode = false
27 28
28 func allPackages() []string { 29 func allPackages() []string {
29 var pkgs []string 30 var pkgs []string
30 root := filepath.Join(runtime.GOROOT(), "src/pkg") + string(os.PathSepar ator) 31 root := filepath.Join(runtime.GOROOT(), "src/pkg") + string(os.PathSepar ator)
31 filepath.Walk(root, func(path string, info os.FileInfo, err error) error { 32 filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
32 // Prune the search if we encounter any of these names: 33 // Prune the search if we encounter any of these names:
33 switch filepath.Base(path) { 34 switch filepath.Base(path) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 runtime.GC() 92 runtime.GC()
92 runtime.ReadMemStats(&memstats) 93 runtime.ReadMemStats(&memstats)
93 94
94 numPkgs := len(prog.AllPackages()) 95 numPkgs := len(prog.AllPackages())
95 if want := 140; numPkgs < want { 96 if want := 140; numPkgs < want {
96 t.Errorf("Loaded only %d packages, want at least %d", numPkgs, w ant) 97 t.Errorf("Loaded only %d packages, want at least %d", numPkgs, w ant)
97 } 98 }
98 99
99 // Dump some statistics. 100 // Dump some statistics.
100 » allFuncs := ssa.AllFunctions(prog) 101 » allFuncs := ssautil.AllFunctions(prog)
101 var numInstrs int 102 var numInstrs int
102 for fn := range allFuncs { 103 for fn := range allFuncs {
103 for _, b := range fn.Blocks { 104 for _, b := range fn.Blocks {
104 numInstrs += len(b.Instrs) 105 numInstrs += len(b.Instrs)
105 } 106 }
106 } 107 }
107 108
108 // determine line count 109 // determine line count
109 var lineCount int 110 var lineCount int
110 imp.Fset.Iterate(func(f *token.File) bool { 111 imp.Fset.Iterate(func(f *token.File) bool {
111 lineCount += f.LineCount() 112 lineCount += f.LineCount()
112 return true 113 return true
113 }) 114 })
114 115
115 // NB: when benchmarking, don't forget to clear the debug + 116 // NB: when benchmarking, don't forget to clear the debug +
116 // sanity builder flags for better performance. 117 // sanity builder flags for better performance.
117 118
118 t.Log("GOMAXPROCS: ", runtime.GOMAXPROCS(0)) 119 t.Log("GOMAXPROCS: ", runtime.GOMAXPROCS(0))
119 t.Log("#Source lines: ", lineCount) 120 t.Log("#Source lines: ", lineCount)
120 t.Log("Load/parse/typecheck: ", t1.Sub(t0)) 121 t.Log("Load/parse/typecheck: ", t1.Sub(t0))
121 t.Log("SSA create: ", t2.Sub(t1)) 122 t.Log("SSA create: ", t2.Sub(t1))
122 t.Log("SSA build: ", t3.Sub(t2)) 123 t.Log("SSA build: ", t3.Sub(t2))
123 124
124 // SSA stats: 125 // SSA stats:
125 t.Log("#Packages: ", numPkgs) 126 t.Log("#Packages: ", numPkgs)
126 t.Log("#Functions: ", len(allFuncs)) 127 t.Log("#Functions: ", len(allFuncs))
127 t.Log("#Instructions: ", numInstrs) 128 t.Log("#Instructions: ", numInstrs)
128 t.Log("#MB: ", (memstats.Alloc-alloc)/1000000) 129 t.Log("#MB: ", (memstats.Alloc-alloc)/1000000)
129 } 130 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b