为什么在Linux 2.6.32比2.6.18相同程序慢? [英] why the same program slower in linux 2.6.32 than 2.6.18?

查看:353
本文介绍了为什么在Linux 2.6.32比2.6.18相同程序慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个程序,它就是这么简单。

I wrote a program, which is so simple.

void do_test() {
    const char *s = "http://";
    int i = 0;
    for(; i<100000; ++i) {
        const char *p = s;
        while(*p != '/') {
            ++p;
        }
    }
}
int main() {
    int i = 0;
    for(; i<100; ++i) {
       do_test();
    }
    return 0;
}

运行此code的100倍,将引领difference.it费用1.29s在我的64位服务器内核的Linux 2.6.32,但它只是成本1.23s在我的32位服务器内核2.6.18。

run this code 100 times,will lead the difference.it costs 1.29s in my 64 bit server with kernel linux 2.6.32, but it just costs 1.23s in my 32 bit server with kernel 2.6.18.

推荐答案

由于硬件不同,性能上的差异可能(而且很可能有)无关的内核。

Since the hardware is different, the difference in performance might have (and very probably has) nothing to do with the kernel.

此外,我想编译器优化,CPU架构等前做好指责内核...

Moreover, I would think of compiler optimizations, CPU architecture, etc. well before blaming the kernel...

这篇关于为什么在Linux 2.6.32比2.6.18相同程序慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆