Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

GC is shit

Name: Anonymous 2011-09-07 9:18

discuss

Name: Anonymous 2012-08-01 6:50

>>174
% cat echo.go
package main
import (
   "fmt"
   "os"
)
func main() {
   //for i := 1; i < len(os.Args); i++ {
   for i, arg := range os.Args[1:] {
       if i != 0 {
           //os.Stdout.WriteString(" ")
           fmt.Print(" ")
       }
       //os.Stdout.WriteString(os.Args[i])
       fmt.Print(arg)
   }
   //os.Stdout.WriteString("\n")
   fmt.Println()
}
% time go build echo.go
go build echo.go  0.77s user 0.08s system 99% cpu 0.860 total
% for i in {1..3}; do time ./echo qwe asd; done
qwe asd
./echo qwe asd  0.01s user 0.00s system 90% cpu 0.011 total
qwe asd
./echo qwe asd  0.01s user 0.00s system 93% cpu 0.012 total
qwe asd
./echo qwe asd  0.00s user 0.00s system 88% cpu 0.011 total

As you can the Go program starts in a few milliseconds.

% cat Echo.java
public class Echo {
   public static void main(String []args) {
       for (int i = 0; i < args.length; i++) {
           if (i != 0) {
               System.out.print(" ");
           }
           System.out.print(args[i]);
       }
       System.out.print("\n");
   }
}
% time javac Echo.java
javac Echo.java  1.87s user 0.18s system 112% cpu 1.834 total
% for i in {1..3}; do time java Echo qwe asd; done
qwe asd
java Echo qwe asd  0.23s user 0.05s system 100% cpu 0.282 total
qwe asd
java Echo qwe asd  0.24s user 0.05s system 101% cpu 0.280 total
qwe asd
java Echo qwe asd  0.23s user 0.05s system 101% cpu 0.279 total

The Java program, on the other hand, takes twice as long to build and needs over 250 ms to run.

% for i in {1..3}; do time go run echo.go qwe asd; done
qwe asd
go run echo.go qwe asd  0.79s user 0.09s system 99% cpu 0.880 total
qwe asd
go run echo.go qwe asd  0.79s user 0.08s system 99% cpu 0.870 total
qwe asd
go run echo.go qwe asd  0.79s user 0.08s system 99% cpu 0.873 total

In comparison, I can compile and run a Go echo in about three times the duration the Java program needs to merely run.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List