I am a beginner in Go. I have two similar codes. One is just a simple hello world and the other is a hello world with additional module urfave/cli/v3. After go build ..., I found the two programs exhibit a significant difference in their execution speeds.
Detail
A simple hello world
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
If not import urfave/cli/v3, instead using other module like cobra, the speed is relatively slow too. But I cannot find any suspicious parts in cli that speeds up the whole program.
For me both versions take about 10ms to run. And for comparison, a C hello world takes about 8 or 9ms on the same system. I used the time command to do the timing. In all cases most of time was system time, not user time.
That’s all on linux, not Windows. On any platform you could in theory use Go’s profiling tools, but in practice a hello world program is too short lived to produce anything useful. On linux you could use strace to get a better picture regarding what’s going on. I don’t know what the equivalent would be on Windows.
I must say that the ~140ns that you saw for the simpler version looks suspiciously fast to me. That’s seems very quick to start a process, send text to stdout, and terminate the process. But then again I know very little about Windows these days.