Closed
Description
by nicolas.riesch:
I installed go 1.3, and ran "go build" on my program with no problem at all. But when I ran "go test", it took one hour to compile. I have already noticed that in go 1.2.2, "go build" was really fast, but that "go test" was strangely slow, taking 2 minutes to compile my program (most of this time being used by the linker 6l). However, the problem is not in the "testing" package or "go test" tool. In fact, the problem is that my test files contain very long arrays, which is usual for table driven tests. Here is a small program with around 500 test records in a "samples" array. http://play.golang.org/p/qpxcVGkzuk Below are the times to build this program. You see that if the "samples" array is local to the test function, the build time is many times worse than when the array is global. And that with go 1.3, the build time is really long. $ time go build go version go1.2.2 linux/amd64 ============================== Build time when "samples" array is inside the main function: real 0m2.437s user 0m2.232s sys 0m0.156s Build time when "samples" array is outside the main function (samples array is a global variable): real 0m0.960s user 0m0.820s sys 0m0.108s go version go1.3 linux/amd64 ============================ Build time when "samples" array is inside the main function: real 0m55.898s user 0m55.228s sys 0m0.228s Build time when "samples" array is outside the main function (samples array is a global variable): real 0m3.833s user 0m3.676s sys 0m0.104s The build time has become 55.9 seconds / 2.4 seconds = 23 times worse in go 1.3 In my real program test files, I have a total of 8000 samples in the "samples" array, and it takes 1 hour to compile. The degradation in the build time is faster than linear.