File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,33 @@ func TestStdlibMetadata(t *testing.T) {
50
50
t .Log ("Metadata: " , t1 .Sub (t0 )) // ~800ms on 12 threads
51
51
t .Log ("#MB: " , int64 (memstats .Alloc - alloc )/ 1000000 ) // ~1MB
52
52
}
53
+
54
+ // BenchmarkNetHTTP measures the time to load/parse/typecheck the
55
+ // net/http package and all dependencies.
56
+ func BenchmarkNetHTTP (b * testing.B ) {
57
+ testenv .NeedsGoPackages (b )
58
+ b .ReportAllocs ()
59
+
60
+ var bytes int64
61
+
62
+ for i := range b .N {
63
+ cfg := & packages.Config {Mode : packages .LoadAllSyntax }
64
+ pkgs , err := packages .Load (cfg , "net/http" )
65
+ if err != nil {
66
+ b .Fatalf ("failed to load metadata: %v" , err )
67
+ }
68
+ if packages .PrintErrors (pkgs ) > 0 {
69
+ b .Fatal ("there were errors loading net/http" )
70
+ }
71
+
72
+ if i == 0 {
73
+ packages .Visit (pkgs , nil , func (pkg * packages.Package ) {
74
+ for _ , f := range pkg .Syntax {
75
+ bytes += int64 (f .FileEnd - f .FileStart )
76
+ }
77
+ })
78
+ }
79
+ }
80
+
81
+ b .SetBytes (bytes ) // total source bytes
82
+ }
You can’t perform that action at this time.
0 commit comments