Created
May 1, 2012 15:18
-
-
Save awreece/2568738 to your computer and use it in GitHub Desktop.
Difference between C and Go
This file contains hidden or 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
#!/bin/bash | |
# Run the program. | |
$1 & | |
# Wait for it to load all its sections. | |
sleep 0.00005 | |
# Print its procmap. | |
cat /proc/$!/maps |
This file contains hidden or 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
all: run_c run_go | |
.PHONY: run_c run_go | |
run_c : sleep_10_ms_c | |
bash catproc.bash $< | |
run_go : sleep_10_ms_go | |
bash catproc.bash $< | |
sleep_10_ms_c : sleep_10_ms.c | |
$(CC) -o $@ $< | |
sleep_10_ms_go : sleep_10_ms.go | |
go build -o $@ $< |
This file contains hidden or 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
bash catproc.bash sleep_10_ms_c | |
08048000-08049000 r-xp 00000000 08:07 2492276 /tmp/sleep_10_ms_c | |
08049000-0804a000 r--p 00000000 08:07 2492276 /tmp/sleep_10_ms_c | |
0804a000-0804b000 rw-p 00001000 08:07 2492276 /tmp/sleep_10_ms_c | |
09272000-09293000 rw-p 00000000 00:00 0 [heap] | |
40000000-4001e000 r-xp 00000000 08:07 4201402 /lib/i386-linux-gnu/ld-2.13.so | |
4001e000-4001f000 r--p 0001d000 08:07 4201402 /lib/i386-linux-gnu/ld-2.13.so | |
4001f000-40020000 rw-p 0001e000 08:07 4201402 /lib/i386-linux-gnu/ld-2.13.so | |
40020000-40021000 r-xp 00000000 00:00 0 [vdso] | |
40021000-40023000 rw-p 00000000 00:00 0 | |
40039000-401b1000 r-xp 00000000 08:07 4205144 /lib/i386-linux-gnu/libc-2.13.so | |
401b1000-401b3000 r--p 00178000 08:07 4205144 /lib/i386-linux-gnu/libc-2.13.so | |
401b3000-401b4000 rw-p 0017a000 08:07 4205144 /lib/i386-linux-gnu/libc-2.13.so | |
401b4000-401b8000 rw-p 00000000 00:00 0 | |
bfded000-bfe0e000 rw-p 00000000 00:00 0 [stack] | |
bash catproc.bash sleep_10_ms_c | |
08048000-08049000 r-xp 00000000 08:07 2492276 /tmp/sleep_10_ms_c | |
08049000-0804a000 r--p 00000000 08:07 2492276 /tmp/sleep_10_ms_c | |
0804a000-0804b000 rw-p 00001000 08:07 2492276 /tmp/sleep_10_ms_c | |
08e70000-08e91000 rw-p 00000000 00:00 0 [heap] | |
40000000-4001e000 r-xp 00000000 08:07 4201402 /lib/i386-linux-gnu/ld-2.13.so | |
4001e000-4001f000 r--p 0001d000 08:07 4201402 /lib/i386-linux-gnu/ld-2.13.so | |
4001f000-40020000 rw-p 0001e000 08:07 4201402 /lib/i386-linux-gnu/ld-2.13.so | |
40020000-40021000 r-xp 00000000 00:00 0 [vdso] | |
40021000-40023000 rw-p 00000000 00:00 0 | |
40039000-401b1000 r-xp 00000000 08:07 4205144 /lib/i386-linux-gnu/libc-2.13.so | |
401b1000-401b3000 r--p 00178000 08:07 4205144 /lib/i386-linux-gnu/libc-2.13.so | |
401b3000-401b4000 rw-p 0017a000 08:07 4205144 /lib/i386-linux-gnu/libc-2.13.so | |
401b4000-401b8000 rw-p 00000000 00:00 0 | |
bff73000-bff94000 rw-p 00000000 00:00 0 [stack] |
This file contains hidden or 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
bash catproc.bash sleep_10_ms_go | |
08048000-0809d000 r-xp 00000000 08:07 2492263 /tmp/sleep_10_ms_go | |
0809d000-080a0000 rw-p 00055000 08:07 2492263 /tmp/sleep_10_ms_go | |
080a0000-084b1000 rw-p 00000000 00:00 0 | |
08500000-184e0000 ---p 00000000 00:00 0 [heap] | |
184e0000-18600000 rwxp 00000000 00:00 0 | |
18600000-38500000 ---p 00000000 00:00 0 | |
40000000-40001000 r-xp 00000000 00:00 0 [vdso] | |
40001000-40171000 rwxp 00000000 00:00 0 | |
bfd16000-bfd37000 rw-p 00000000 00:00 0 [stack] | |
bash catproc.bash sleep_10_ms_go | |
08048000-0809d000 r-xp 00000000 08:07 2492263 /tmp/sleep_10_ms_go | |
0809d000-080a0000 rw-p 00055000 08:07 2492263 /tmp/sleep_10_ms_go | |
080a0000-084b1000 rw-p 00000000 00:00 0 | |
08500000-184e0000 ---p 00000000 00:00 0 [heap] | |
184e0000-18600000 rwxp 00000000 00:00 0 | |
18600000-38500000 ---p 00000000 00:00 0 | |
40000000-40001000 r-xp 00000000 00:00 0 [vdso] | |
40001000-40191000 rwxp 00000000 00:00 0 | |
bfdbb000-bfddc000 rw-p 00000000 00:00 0 [stack] |
This file contains hidden or 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
#include <unistd.h> | |
#include <stdlib.h> | |
int main(int argc, char** argv) { | |
free(malloc(1)); // To ensure that the heap is loaded. | |
usleep(10*1000); | |
return 0; | |
} |
This file contains hidden or 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 "time" | |
func main() { | |
<-time.After(time.Millisecond*10) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment