我正在运行以下程序:
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)但是,在硬件完全相同的机器上,一个运行ubuntu10.04,另一个运行14.04。我观察到10.04需要1409.54秒,14.04需要1656.81秒,14.04显示性能下降17%。有什么想法吗?
发布于 2015-09-29 05:25:45
这种行为是由14.04超线程造成的。有趣的是,在我的2核心机器上禁用了超级线程(并且有效地运行在一个超级线程上)之后,14.04提供了与10.04相同的性能。
https://stackoverflow.com/questions/32434240
复制相似问题