3 ms·
Go run first compiles the code and builds an executable. You are mostly benchmarking for both systems the compilation time. Building an executable in Go takes m
by _ph_ 11y ago
Go run first compiles the code and builds an executable. You are mostly benchmarking for both systems the compilation time. Building an executable in Go takes most of a second. A significant benchmark would check the run times.
- artursapek 11y agoExactly. Build it and then benchmark the binary. Nobody uses `go run` in production.
- hughw 11y agoNo, if you examine the code, you'll see the timer times only the accumulated execution time for the loop. The code has been compiled. See below to eliminate doubt -- I used go build and got similar numbers.