$ javac Main.java
$ time java Main
java Main 5.91s user 0.29s system 102% cpu 6.053 total
$ go build -o main
$ time ./main
./main 33.44s user 3.35s system 117% cpu 31.391 total
Last active
August 29, 2015 14:02
-
-
Save nise-nabe/8c5b8a75940d2739b67e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"runtime" | |
) | |
func init() { | |
runtime.GOMAXPROCS(runtime.NumCPU()) | |
} | |
func main () { | |
for i := 0; i < 10000; i++ { | |
m := make(map[int]int) | |
for j := 0; j < 10000; j++ { | |
if _, exist := m[j]; !exist { | |
m[j] = i | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import java.util.HashMap; | |
class Main { | |
public static void main(String[] args){ | |
for (int i = 0; i < 10000; i++) { | |
Map<Integer, Integer> m = new HashMap<Integer, Integer>(); | |
for (int j = 0; j < 10000; j++) { | |
if (!m.containsKey(j)) { | |
m.put(j, i); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment