OSDN Git Service

Update to current Go testsuite.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / bench / garbage / parser.go
@@ -12,27 +12,27 @@ import (
        "go/ast"
        "go/parser"
        "go/token"
+       "log"
+       "net/http"
+       _ "net/http/pprof"
        "os"
        "path"
        "runtime"
        "strings"
        "time"
-       "http"
-       _ "http/pprof"
-       "log"
 )
 
 var serve = flag.String("serve", "", "serve http on this address at end")
 
-func isGoFile(dir *os.FileInfo) bool {
-       return dir.IsRegular() &&
-               !strings.HasPrefix(dir.Name, ".") && // ignore .files
-               path.Ext(dir.Name) == ".go"
+func isGoFile(dir os.FileInfo) bool {
+       return !dir.IsDir() &&
+               !strings.HasPrefix(dir.Name(), ".") && // ignore .files
+               path.Ext(dir.Name()) == ".go"
 }
 
-func isPkgFile(dir *os.FileInfo) bool {
+func isPkgFile(dir os.FileInfo) bool {
        return isGoFile(dir) &&
-               !strings.HasSuffix(dir.Name, "_test.go") // ignore test files
+               !strings.HasSuffix(dir.Name(), "_test.go") // ignore test files
 }
 
 func pkgName(filename string) string {
@@ -49,7 +49,7 @@ func parseDir(dirpath string) map[string]*ast.Package {
        _, pkgname := path.Split(dirpath)
 
        // filter function to select the desired .go files
-       filter := func(d *os.FileInfo) bool {
+       filter := func(d os.FileInfo) bool {
                if isPkgFile(d) {
                        // Some directories contain main packages: Only accept
                        // files that belong to the expected package so that
@@ -57,7 +57,7 @@ func parseDir(dirpath string) map[string]*ast.Package {
                        // found" errors.
                        // Additionally, accept the special package name
                        // fakePkgName if we are looking at cmd documentation.
-                       name := pkgName(dirpath + "/" + d.Name)
+                       name := pkgName(dirpath + "/" + d.Name())
                        return name == pkgname
                }
                return false
@@ -66,17 +66,13 @@ func parseDir(dirpath string) map[string]*ast.Package {
        // get package AST
        pkgs, err := parser.ParseDir(token.NewFileSet(), dirpath, filter, parser.ParseComments)
        if err != nil {
-               println("parse", dirpath, err.String())
+               println("parse", dirpath, err.Error())
                panic("fail")
        }
        return pkgs
 }
 
 func main() {
-       runtime.GOMAXPROCS(4)
-       go func() {}()
-       go func() {}()
-       go func() {}()
        st := &runtime.MemStats
        packages = append(packages, packages...)
        packages = append(packages, packages...)
@@ -86,7 +82,7 @@ func main() {
        flag.Parse()
 
        var lastParsed []map[string]*ast.Package
-       var t0 int64
+       var t0 time.Time
        pkgroot := runtime.GOROOT() + "/src/pkg/"
        for pass := 0; pass < 2; pass++ {
                // Once the heap is grown to full size, reset counters.
@@ -95,7 +91,7 @@ func main() {
                // the average look much better than it actually is.
                st.NumGC = 0
                st.PauseTotalNs = 0
-               t0 = time.Nanoseconds()
+               t0 = time.Now()
 
                for i := 0; i < *n; i++ {
                        parsed := make([]map[string]*ast.Package, *p)
@@ -109,7 +105,7 @@ func main() {
                runtime.GC()
                runtime.GC()
        }
-       t1 := time.Nanoseconds()
+       t1 := time.Now()
 
        fmt.Printf("Alloc=%d/%d Heap=%d Mallocs=%d PauseTime=%.3f/%d = %.3f\n",
                st.Alloc, st.TotalAlloc,
@@ -124,7 +120,7 @@ func main() {
                }
        */
        // Standard gotest benchmark output, collected by build dashboard.
-       gcstats("BenchmarkParser", *n, t1-t0)
+       gcstats("BenchmarkParser", *n, t1.Sub(t0))
 
        if *serve != "" {
                log.Fatal(http.ListenAndServe(*serve, nil))
@@ -132,23 +128,20 @@ func main() {
        }
 }
 
-
 var packages = []string{
        "archive/tar",
-       "asn1",
-       "big",
+       "encoding/asn1",
+       "math/big",
        "bufio",
        "bytes",
-       "cmath",
+       "math/cmplx",
        "compress/flate",
        "compress/gzip",
        "compress/zlib",
        "container/heap",
        "container/list",
        "container/ring",
-       "container/vector",
        "crypto/aes",
-       "crypto/block",
        "crypto/blowfish",
        "crypto/hmac",
        "crypto/md4",
@@ -167,20 +160,14 @@ var packages = []string{
        "debug/macho",
        "debug/elf",
        "debug/gosym",
-       "debug/proc",
-       "ebnf",
+       "exp/ebnf",
        "encoding/ascii85",
        "encoding/base64",
        "encoding/binary",
        "encoding/git85",
        "encoding/hex",
        "encoding/pem",
-       "exec",
-       "exp/datafmt",
-       "exp/draw",
-       "exp/eval",
-       "exp/iterable",
-       "expvar",
+       "os/exec",
        "flag",
        "fmt",
        "go/ast",
@@ -189,18 +176,18 @@ var packages = []string{
        "go/printer",
        "go/scanner",
        "go/token",
-       "gob",
+       "encoding/gob",
        "hash",
        "hash/adler32",
        "hash/crc32",
        "hash/crc64",
-       "http",
+       "net/http",
        "image",
        "image/jpeg",
        "image/png",
        "io",
        "io/ioutil",
-       "json",
+       "encoding/json",
        "log",
        "math",
        "mime",
@@ -209,29 +196,29 @@ var packages = []string{
        "os/signal",
        "patch",
        "path",
-       "rand",
+       "math/rand",
        "reflect",
        "regexp",
-       "rpc",
+       "net/rpc",
        "runtime",
-       "scanner",
+       "text/scanner",
        "sort",
-       "smtp",
+       "net/smtp",
        "strconv",
        "strings",
        "sync",
        "syscall",
-       "syslog",
-       "tabwriter",
-       "template",
+       "log/syslog",
+       "text/tabwriter",
+       "text/template",
        "testing",
        "testing/iotest",
        "testing/quick",
        "testing/script",
        "time",
        "unicode",
-       "utf8",
-       "utf16",
+       "unicode/utf8",
+       "unicode/utf16",
        "websocket",
-       "xml",
+       "encoding/xml",
 }