Python论坛  - 讨论区

标题:[python-chinese] Ruby1.9运算性能超过Python2.5.1

2007年12月01日 星期六 11:30

vicalloy zbirder在gmail.com
星期六 十二月 1 11:30:30 HKT 2007

我确定用的是release。

在 07-11-30,Leo Jay<python.leojay在gmail.com> 写道:
> On Nov 30, 2007 9:59 PM, vicalloy <zbirder在gmail.com> wrote:
> > 这个测试简单,在我机器上测了下。
> > JAVA最快,比native的Delphi还快些。
> > jdk1.6              52594/100=      0.52594s
> > delphi7           1m05s/100=     0.65s
> > VC6                 1m11s/100=     0.71s
> >
> > 测试环境:
> > CPU:Turion64x2 1.6G
> > 内存:2G
> > 虽然CPU是双核的,但似乎这些程序都只用到了一个核心。
> >
> > [...]
> >
> > ===============VC6===============
> >         fib(int n) {
> >                 if (n == 0 || n == 1)
> >                         return n;
> >                 else
> >                         return fib(n - 1) + fib(n - 2);
> >         }
> >
> >         void t() {
> >                 for (int i = 0; i < 36; i++) {
> >                         fib(i);
> >                 }
> >         }
> >
>
>
> 你在用debug版的程序在做比较?
> 用VC的话,release版你这段程序一定会被优化掉的。
> 因为那段fib只做数值的计算,而计算的结果完全没有被使用,
> 这种代码段是会被优化掉的。release版本的运行时间一定是0。
> C/C++的程序你用debug版本做比较,不能说明任何问题吧?
>
> 你在函数前面声明一个int sum=0;把fib(i)那里写成sum+=fib(i),然后打印这个sum,用release版看看时间。
> 这种简单程序(在同样的算法下)是没有可能有什么语言比C快的。你看过生成的汇编代码就知道了。
>
> --
> Best Regards,
> Leo Jay
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


-- 
Blog http://vicalloy.spaces.live.com/
My googlepage http://vicalloy.googlepages.com/
OldPhoto http://www.lzpian.com/

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号