• 3381阅读
  • 0回复

Tips for efficiency [复制链接]

上一主题 下一主题
离线steinlee
 

只看楼主 倒序阅读 楼主  发表于: 2008-08-13
— 本帖被 XChinux 执行加亮操作(2008-08-13) —
1. make use of multi-core CPU:
    if you have multi-core CPU, you can speed-up compiling of your code by doing the following:
      make -j4 (if you have 2-core CPU) or
      make -j5 (if you have 3-core CPU) or
      make -j6 (if you have 4-core CPU)
This is parallel compiling on one computer. To determine the number of cores in your CPU, use the following command
      cat /proc/cpuinfo | grep processor | wc -l
I define it in my shell as
    alias numcpu='cat /proc/cpuinfo | grep processor | wc -l'

2. use ccache
    ccache can be installed on Ubuntu with
      sudo apt-get install ccache
After this is done, make changes in the Makefile like
CC      = ccache gcc
CXX      = ccache g++

When the code is recompiled, you will see clear speed-up.
Looking for remote C/C++ and Qt 兼职
快速回复
限100 字节
 
上一个 下一个