home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11636 < prev    next >
Encoding:
Text File  |  1992-07-27  |  2.7 KB  |  114 lines

  1. Xref: sparky comp.lang.c++:11636 comp.lang.eiffel:992
  2. Path: sparky!uunet!stanford.edu!bcm!cs.utexas.edu!tamsun.tamu.edu!ychang
  3. From: ychang@cs.tamu.edu (Yeimkuan Chang)
  4. Newsgroups: comp.lang.c++,comp.lang.eiffel
  5. Subject: Interesting results of Borland's compilers
  6. Keywords: Borland
  7. Message-ID: <1992Jul27.215710.21666@tamsun.tamu.edu>
  8. Date: 27 Jul 1992 21:57:10 GMT
  9. Sender: news@tamsun.tamu.edu (Read News)
  10. Organization: Computer Science Department, Texas A&M University
  11. Lines: 101
  12.  
  13. Hi:
  14.    I have interesting results of a simple program which is attached at 
  15.    the end of this post. What the program does is only the floating point
  16.    assignment. But the execution speed has a very big difference, 15 and
  17.    69 seconds compiled by Turboc C 2.0 and Borland C++ 1.5, respectively.
  18.    The compiler options are large model and 80286 instruction set. If the
  19.    program performs floating point multiplicaton and division, the difference 
  20.    will be much bigger.
  21.  
  22.    My questions are:
  23.    1. what the results showed above imply? I thought the more recent 
  24.       Borland compiler should give us better performance.
  25.    2. How about Borland C++ 2.0 or 2.1? Can any one test it since I can not 
  26.       access these compilers right now.
  27.    3. If the program has something wrong, please tell me.
  28.  
  29.    Albert
  30.  
  31. p.s. the PC I used to test this program is clone AT 286.
  32.  
  33. -------- code of the test program ---------------
  34. #include <stdio.h>
  35. #include <time.h>
  36. #include <sys\timeb.h>
  37.  
  38. /*#define DEBUG
  39.   */
  40.  
  41. void rantest();
  42. /*void rantest(struct block_type *a, int size);
  43. print_time_diff(struct timeb *bt, struct timeb *et);
  44.   */
  45.  
  46. #define NUM 2000
  47. float n[NUM];
  48. main()
  49. {
  50. /* struct block_type a;*/
  51.  
  52.  struct timeb bt, et;
  53.  
  54.  ftime(&bt);
  55.  #if defined(DEBUG)
  56.  printf("%ld.%d\n", bt.time, bt.millitm);
  57.  #endif
  58. /* rantest(n, 100);*/
  59. rantest(NUM);
  60.  
  61.  ftime(&et);
  62.  
  63.  #if defined(DEBUG)
  64.  printf("%ld.%d\n", et.time, et.millitm);
  65.  #endif
  66.  print_time_diff(&bt,&et);
  67. }
  68.  
  69. print_time_diff(bt,et)
  70. struct timeb *bt, *et;
  71. {
  72.  struct timeb t;
  73.  
  74.  if(et->millitm < bt->millitm){
  75.    t.millitm = et->millitm+1000 - bt->millitm;
  76.    et->time = et->time - 1;
  77.  } else t.millitm  = et->millitm - bt->millitm;
  78.  
  79.  t.time = et->time - bt->time;
  80.  printf("%ld.%d\n", t.time, t.millitm);
  81.  
  82. }
  83.  
  84. void rantest(size)
  85. int size;
  86. {
  87.  int i, j;
  88.  int k1, k2, k3;
  89.  float t;
  90.  
  91.  for(i=0; i<size; i++){
  92.    n[i] = (float) i/100.0;
  93.    #if defined(DEBUG)
  94.     if(i%5==0 && i!=0) printf("\n");
  95.     printf("%f ", n[i]);
  96.    #endif
  97.  }
  98.  #if defined(DEBUG)
  99.  if(i%5==0 && i!=0) printf("\n");
  100.  #endif
  101.  
  102.  k1 = 0; k2 = 33; k3 = 66;
  103.  for(j=0; j<100; j++)
  104.  for(i=0; i<10000; i++){
  105.     t = n[k1];
  106.     t = n[k2];
  107.     t = n[k3];
  108.     k1++; k2++; k3++;
  109.     if(k1 == size) k1 = 0;
  110.     if(k2 == size) k2 = 0;
  111.     if(k3 == size) k3 = 0;
  112.  }
  113. }
  114.