运算与时间(G++、Ubuntu 8.0.4、dell dimension 5150)

乘法运算
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     time_t start,end;
  8.     struct tm* time_start,* time_end;
  9.     time(&start);
  10.     time_start = localtime(&start);
  11.     printf("start time is: %s/n",asctime(time_start));
  12.     double j=0;
  13.     for (int k=0;k<10;k++)
  14.     for (int i=0;i<100000000;i++)
  15.     {
  16.         j*0.1232345;
  17.     }
  18.     time(&end);
  19.     time_end = localtime(&end);
  20.     printf("end time is: %s/n",asctime(time_end));
  21.     return 0;
  22. }
相同的运算规模,花了2秒钟,和XP、debug模式下效率差不多。不过,VC下可以使用release进行优化,我现在在linux下还不懂得如何优化程序呢。

你可能感兴趣的:(运算与时间(G++、Ubuntu 8.0.4、dell dimension 5150))