节省编译时间的工具
Tools save compiling time
最近发现编译C++程序很花时间。
比如说仅仅编译一个用了模版库的程序需要花10秒。
为了加快开发速度,我想找一个能提高单机编译速度的程序。结果如下:
[table caption=”Benchmark” width=”500″ colalign=”left|left|right|right|right”]
Program,UserTime (s),SysTime (s),RealTime (s)[attr style=”color:red” sort=”desc”],Memory (kB)
g++-4.9.4,137.35u,10.11s,56.44r,1392268kB
clang++-4.0,93.24u,6.56s,36.21r[attr style=”color:red” sort=”desc”],949524kB
zapcc++-1.0,1.81u,0.57s,33.95r[attr style=”color:red” sort=”desc”],39888kB
ccache-g++ (1st),109.62u,9.01s,49.43r,1392392kB
ccache-g++ (2nd),1.47u,0.87s,1.67r[attr style=”color:red” sort=”desc”],55832kB
[/table]
结论:
从编译速度来看,首次编译速度最快的是zapcc(不免费)和clang(免费),耗时~35秒左右,比g++快40%。
重复编译的时候ccache最快,提速10倍以上。
注:表中zapcc的用户时间很短,内容占用少,这是因为它是起动其他进程去真正编译,其他程序的用户时间和内存使用没有被计入。