home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:11636 comp.lang.eiffel:992
- Path: sparky!uunet!stanford.edu!bcm!cs.utexas.edu!tamsun.tamu.edu!ychang
- From: ychang@cs.tamu.edu (Yeimkuan Chang)
- Newsgroups: comp.lang.c++,comp.lang.eiffel
- Subject: Interesting results of Borland's compilers
- Keywords: Borland
- Message-ID: <1992Jul27.215710.21666@tamsun.tamu.edu>
- Date: 27 Jul 1992 21:57:10 GMT
- Sender: news@tamsun.tamu.edu (Read News)
- Organization: Computer Science Department, Texas A&M University
- Lines: 101
-
- Hi:
- I have interesting results of a simple program which is attached at
- the end of this post. What the program does is only the floating point
- assignment. But the execution speed has a very big difference, 15 and
- 69 seconds compiled by Turboc C 2.0 and Borland C++ 1.5, respectively.
- The compiler options are large model and 80286 instruction set. If the
- program performs floating point multiplicaton and division, the difference
- will be much bigger.
-
- My questions are:
- 1. what the results showed above imply? I thought the more recent
- Borland compiler should give us better performance.
- 2. How about Borland C++ 2.0 or 2.1? Can any one test it since I can not
- access these compilers right now.
- 3. If the program has something wrong, please tell me.
-
- Albert
-
- p.s. the PC I used to test this program is clone AT 286.
-
- -------- code of the test program ---------------
- #include <stdio.h>
- #include <time.h>
- #include <sys\timeb.h>
-
- /*#define DEBUG
- */
-
- void rantest();
- /*void rantest(struct block_type *a, int size);
- print_time_diff(struct timeb *bt, struct timeb *et);
- */
-
- #define NUM 2000
- float n[NUM];
- main()
- {
- /* struct block_type a;*/
-
- struct timeb bt, et;
-
- ftime(&bt);
- #if defined(DEBUG)
- printf("%ld.%d\n", bt.time, bt.millitm);
- #endif
- /* rantest(n, 100);*/
- rantest(NUM);
-
- ftime(&et);
-
- #if defined(DEBUG)
- printf("%ld.%d\n", et.time, et.millitm);
- #endif
- print_time_diff(&bt,&et);
- }
-
- print_time_diff(bt,et)
- struct timeb *bt, *et;
- {
- struct timeb t;
-
- if(et->millitm < bt->millitm){
- t.millitm = et->millitm+1000 - bt->millitm;
- et->time = et->time - 1;
- } else t.millitm = et->millitm - bt->millitm;
-
- t.time = et->time - bt->time;
- printf("%ld.%d\n", t.time, t.millitm);
-
- }
-
- void rantest(size)
- int size;
- {
- int i, j;
- int k1, k2, k3;
- float t;
-
- for(i=0; i<size; i++){
- n[i] = (float) i/100.0;
- #if defined(DEBUG)
- if(i%5==0 && i!=0) printf("\n");
- printf("%f ", n[i]);
- #endif
- }
- #if defined(DEBUG)
- if(i%5==0 && i!=0) printf("\n");
- #endif
-
- k1 = 0; k2 = 33; k3 = 66;
- for(j=0; j<100; j++)
- for(i=0; i<10000; i++){
- t = n[k1];
- t = n[k2];
- t = n[k3];
- k1++; k2++; k3++;
- if(k1 == size) k1 = 0;
- if(k2 == size) k2 = 0;
- if(k3 == size) k3 = 0;
- }
- }
-