]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/api: add a benchmark over the standard library
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 8 Aug 2013 22:25:15 +0000 (15:25 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 8 Aug 2013 22:25:15 +0000 (15:25 -0700)
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12603045

src/cmd/api/goapi_test.go

index a1e762bafcf0100979873d3bcaa45293dcda0236..b909c32b342dca929fbf76ecf60ff58925feefaa 100644 (file)
@@ -10,8 +10,10 @@ import (
        "bytes"
        "flag"
        "fmt"
+       "go/build"
        "io/ioutil"
        "os"
+       "os/exec"
        "path/filepath"
        "sort"
        "strings"
@@ -139,3 +141,28 @@ func TestCompareAPI(t *testing.T) {
                }
        }
 }
+
+func BenchmarkAll(b *testing.B) {
+       stds, err := exec.Command("go", "list", "std").Output()
+       if err != nil {
+               b.Fatal(err)
+       }
+       b.ResetTimer()
+       pkgNames := strings.Fields(string(stds))
+
+       for _, c := range contexts {
+               c.Compiler = build.Default.Compiler
+       }
+
+       for i := 0; i < b.N; i++ {
+               for _, context := range contexts {
+                       w := NewWalker(context, filepath.Join(build.Default.GOROOT, "src/pkg"))
+                       for _, name := range pkgNames {
+                               if name != "unsafe" && !strings.HasPrefix(name, "cmd/") {
+                                       w.export(w.Import(name))
+                               }
+                       }
+                       w.Features()
+               }
+       }
+}