- 论坛徽章:
- 0
|
比较似乎意义不大.
- import time
- class timer:
- def __init__(self):
- self.start= time.time()
- def stop(self):
- self.end= time.time()
- return "with %f seconds"% (self.end-self.start)
- clock=timer()
- n=1
- while n<100000000:
- n+=1
- print clock.stop()
- print n
复制代码
with 31.234000 seconds
100000000
- #include <stdio.h>
- #include <time.h>
- void main()
- {
- clock_t start,end;
- start=clock();
- long int n=0;
- while(n<100000000)
- n+=1;
- end=clock();
- printf("with %f seconds\n",(double)(end-start)/CLK_TCK);
- printf("%ld\n",n);
- }
复制代码
with 0.421000 seconds
100000000
嘿嘿,php还是没C快吧. 尽管python......, 还是喜欢python. |
|