home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18812 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  1.8 KB

  1. Path: sparky!uunet!usc!srhqla!quest!kdq
  2. From: kdq@quest.UUCP (Kevin D. Quitt)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: System Testing
  5. Message-ID: <LZP8VB2w165w@quest.UUCP>
  6. Date: Tue, 22 Dec 92 17:58:08 PST
  7. References: <1992Dec21.172506.6739@colorado.edu>
  8. Reply-To: srhqla!quest!kdq
  9. Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210
  10. Lines: 39
  11.  
  12. stasica@alumni.cs.colorado.edu (The Legacy) writes:
  13. > void memory_test()
  14. > {
  15. >     int *p, i;
  16. >     p=malloc(8388608);       /* Malloc 8M memory */
  17. >     for (i=0;i<8388600;i++)  /* Write to all 8M 1 char at a time */
  18. >         *(p+i)='\0';  /* BTW this doesn't work....why??? (memory violation)*/
  19.  
  20.     Perhaps because p is a null pointer?  You should always check the
  21. return from malloc.
  22.  
  23. > void cpu_test()
  24. > {
  25. >     int i; double d;
  26. >     for (i=0;i<30000000;i++)    /* Do a bunch of calculations */
  27. >         d=(23423423+2394823/234763287*3276472364/2347632+23876322-123123)/237
  28.  
  29.     Any compiler worth its salt will reduce this loop to no code at
  30. all.  It you're going to do this, try something like d += (double)i++;
  31. Of course, a REALLY clever compiler could replace that with
  32.  
  33.     d = 30000000 * 30000001 / 2;
  34.  
  35.     and then just generate the single assignment, or drop it altogether.
  36.  
  37.  
  38.     If you want to benchmark your system, you should examine some of
  39. the standard benchmark programs, like whetstone and dhrystone to see
  40. what they do to overcome compiler cleverness.  Also important to
  41. remember is that benchmarks are of little meaning if the computers are
  42. significantly different in architecture; even comparing between 68000s
  43. and 68020s can lead to some bogus results (with the 68000 coming in
  44. ahead!).  If you can't find anything you like at simtel, send me a
  45. note and I'll ship you my collection.
  46.  
  47.  
  48.  _
  49. Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
  50.