比较旧/新CPU上的C ++开销时的奇怪结果

时间:2014-11-17 18:59:52

标签: c++ performance containers cpu

我有这个C ++代码:

将10000个初始化的学生生成一个容器。 按字母顺序对学生进行排序。 对学生进行排序并通过失败。 将结果输出到控制台。

为了提高效率,使用不同的容器类型(静态和非静态)来执行定时来保持&迭代10000名学生。

没有从文件中读取任何内容,所有学生数据都包含在代码中。

这是使用的两个CPU之间的基准比较,从结果中可以明显看出一个是新的,一个是旧的:

http://cpuboss.com/cpus/Intel-Core-i7-3770K-vs-AMD-Opteron-170#performance

以下是比较每个CPU执行时间的结果....任何想法为什么新CPU被旧cpu留下了? :

-------------------------------------------------------------------------
AMD Opteron 170 - STATIC VECTOR ( 10,000 students =  27.499 secs )
-------------------------------------------------------------------------
gen_students = 1250ms   1.25s
sort_students = 9953ms   9.953s
alpha_pass = 7937ms   7.937s
pass_fail = 8359ms   8.359s

-------------------------------------------------------------------------
i7-3770K@3.5GHz - STATIC VECTOR ( 10,000 students =  46.675 secs )
-------------------------------------------------------------------------
gen_students = 2184ms   2.184s
sort_students = 32713ms   32.713s
alpha_pass = 5164ms   5.164s
pass_fail = 6614ms   6.614s



-------------------------------------------------------------------------
AMD Opteron 170 - STATIC LIST ( 10,000 students =  32.515 secs )
-------------------------------------------------------------------------
gen_students = 890ms   0.89s
sort_students = 15875ms   15.875s
alpha_pass = 7765ms   7.765s
pass_fail = 7985ms   7.985s

-------------------------------------------------------------------------
i7-3770K@3.5GHz - STATIC LIST ( 10,000 students =  27.221 secs )
-------------------------------------------------------------------------
gen_students = 374ms   0.374s
sort_students = 17160ms   17.16s
alpha_pass = 4633ms   4.633s
pass_fail = 5054ms   5.054s



-------------------------------------------------------------------------
AMD Opteron 170 - VECTOR ( 10,000 students =  552.094 secs )
-------------------------------------------------------------------------
gen_students = 1235ms   1.235s
sort_students = 534765ms   534.765s
alpha_pass = 7750ms   7.75s
pass_fail = 8344ms   8.344s

-------------------------------------------------------------------------
i7-3770K@3.5GHz - VECTOR ( 10,000 students =  896.07 secs )
-------------------------------------------------------------------------
gen_students = 2200ms   2.2s
sort_students = 882435ms   882.435s
alpha_pass = 4696ms   4.696s
pass_fail = 6739ms   6.739s



-----------------------------------------------------------
AMD Opteron 170 - LIST ( 10,000 students =  787.984 secs )
-----------------------------------------------------------
gen_students = 906ms   0.906s
sort_students = 771422ms   771.422s
alpha_pass = 7844ms   7.844s
pass_fail = 7812ms   7.812s

-------------------------------------------------------------------------
i7-3770K@3.5GHz - LIST ( 10,000 students =  398.645 secs )
-------------------------------------------------------------------------
gen_students = 358ms   0.358s
sort_students = 388412ms   388.412s
alpha_pass = 4758ms   4.758s
pass_fail = 5117ms   5.117s

1 个答案:

答案 0 :(得分:2)

Opteron 170(旧版)计算机的二级缓存是新计算机的两倍,这对内存密集型操作有很大影响。当两个访问项目彼此靠近时,缓存效果最为明显 - 就像它们使用矢量一样 - 这正是我们在这里看到的。