我正在运行以下程序:
import cStringIO
import time
import threading
def func(tid):
buff = 'a'*4096
i = 0
while (i < 40000000):
output = cStringIO.StringIO()
output.write(buff)
contents = output.getvalue()
output.close()
i = i + 1
threads = 16
threadlist = []
start = time.time()
for tc in range(threads):
thr = threading.Thread(target=func, args=(tc,))
threadlist.append(thr)
thr.start()
for thr in threadlist:
thr.join()
end = time.time()
print "Time taken is %s" % (end - start)
在具有完全相同硬件的机器上,但一台运行 ubuntu 10.04,另一台运行 14.04。我观察到 10.04 需要 1409.54 秒,而 14.04 需要 1656.81 秒,显示 14.04 性能下降 17%。有任何想法吗?