* * * * *
It's a stupid benchmark about compiling a million lines of code, what else
did I expect?
I came across a claim that the V programming langauge [1] can compile 1.2
million lines of code per second [2]. Then I found out that the code was
pretty much just 1,200,000 calls to println('hello world'). Still, I was
interested in seeing how GCC (Gnu's Not Unix Compiler Collection) [3] would
fare. So I coded up this:
-----[ C ]-----
#include <stdio.h>
int main(void)
{
printf("Hello world!\n");
/* 1,199,998 more calls to printf() */
printf("Hello world!\n");
return 0;
}
-----[ END OF LINE ]-----
which ends up being 33M (Megabyte), and …
-----[ shell ]-----
[spc]lucy:/tmp>time gcc h.c
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See <URL:
http://bugzilla.redhat.com/bugzilla> for instructions.
real 14m36.527s
user 0m40.282s
sys 0m17.497s
[spc]lucy:/tmp>
-----[ END OF LINE ]-----
Fourteen minutes for GCC (Gnu's Not Unix Compiler Collection) to figure out I
didn't have enough memory on the 32-bit system to compile it (and the
resulting core file exceeded physical memory by three times). I then tried on
a 64-bit system with a bit more memory, and I fared a bit better:
-----[ shell ]-----
[spc]saltmine:/tmp>time gcc h.c
real 7m37.555s
user 2m3.000s
sys 1m23.353s
[spc]saltmine:/tmp>
-----[ END OF LINE ]-----
This time I got a 12M executable in 7½ minutes, which seems a bit long to me
for such a simple (but large) program. I mean, Lua was able to compile an 83M
script in 6 minutes [4], on the same 32-bit system as above, and that was
considered a bug [5]!
But I used GCC, which does some optimizations by default. Perhaps if I try no
optimization?
-----[ shell ]-----
[spc]saltmine:/tmp>time gcc -O0 h.c
real 7m6.939s
user 2m2.972s
sys 1m27.237s
[spc]saltmine:/tmp>
-----[ END OF LINE ]-----
Wow. A whole 30 seconds faster. Way to go, GCC! Woot!
[1]
https://github.com/vlang/v
[2]
https://lobste.rs/s/rh1pbo/v_source_code_released#c_u4dyn7
[3]
https://gcc.gnu.org/
[4]
http://lua-users.org/lists/lua-l/2009-11/msg00463.html
[5]
https://www.lua.org/bugs.html#5.1.4-6
Email author at
[email protected]