你敢跑这段Python脚本吗?
哈哈,有点开玩笑的意思了。
不过让我有机会了解了Python的效率。我的机器配置为P4 3.0G、Memory为1.5G DDR400。
import timeimport math#import psycodef test(): t=time.time() for j in range(100000000): s=math.sqrt(j) print 'Using',time.time() - t,'seconds!'#test = psyco.proxy(test)test()
#include <iostream>#include <cmath>#include <ctime>int main(){ using namespace std; clock_t start = clock(); for(int i=0; i < 100000000; ++i) double s=sqrt(static_cast<double>(i)); clock_t finish = clock(); cout << "using " << (double)(finish - start) / CLOCKS_PER_SEC << " seconds!\n"; return 0;}
use strict;use warnings;sub test{ my $t=time(); my $i=0; my $s; foreach $i (1..100000000) { $s=sqrt($i); } print('Using ',time() - $t,' seconds!');}test();