在 Ubuntu 8.04 x86 上编译 coreutils-8.4
启用了 HT 的 Intel Atom 1.6 GHz:
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null
real 2m33.375s
user 2m22.873s
sys 0m10.541s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null
real 1m54.707s
user 3m26.121s
sys 0m13.821s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null
real 2m33.372s
user 2m22.753s
sys 0m10.657s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null
real 1m54.851s
user 3m26.145s
sys 0m13.685s
~/coreutils-8.4$
所以超线程将运行时间减少到 75%,相当于增加了33% 的处理能力。(我运行了两次以确保所有内容都在内存缓存中。)
这是一个对照实验,表明make -j2
单独并不能提高在 Ubuntu 8.04 x86 上编译 coreutils-8.4 的速度
单核 Core 2 Quad 2.5 GHz VM(无 HT):
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null
real 0m44.453s
user 0m38.870s
sys 0m5.500s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null
real 0m45.131s
user 0m40.450s
sys 0m4.580s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null
real 0m44.621s
user 0m39.090s
sys 0m5.340s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null
real 0m45.165s
user 0m40.390s
sys 0m4.610s
~/coreutils-8.4$