home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18747 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.1 KB  |  59 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!boulder!alumni.cs.colorado.edu!stasica
  3. From: stasica@alumni.cs.colorado.edu (The Legacy)
  4. Subject: System Testing
  5. Message-ID: <1992Dec21.172506.6739@colorado.edu>
  6. Sender: news@colorado.edu (The Daily Planet)
  7. Nntp-Posting-Host: alumni.cs.colorado.edu
  8. Organization: Damage, Inc.
  9. References: <gs-310856102441@gs.statlab.uni-heidelberg.de>
  10. Date: Mon, 21 Dec 1992 17:25:06 GMT
  11. Lines: 46
  12.  
  13.  
  14. I'll try this again since no one answered it the first time.
  15.  
  16. I am trying to test system memory, I/O, and CPU.
  17.  
  18. Here are some very simple, yet intensive busy work routines I have written.
  19. Can someone give me an idea if these are valid at all or should I go about
  20. the algorithm via some other "C" methods:
  21.  
  22. void memory_test()
  23. {
  24.     int *p, i;
  25.     p=malloc(8388608);       /* Malloc 8M memory */
  26.     for (i=0;i<8388600;i++)  /* Write to all 8M 1 char at a time */
  27.         *(p+i)='\0';  /* BTW this doesn't work....why??? (memory violation)*/
  28.     free(p);
  29. }
  30.  
  31. void cpu_test()
  32. {
  33.     int i; double d;
  34.     for (i=0;i<30000000;i++)    /* Do a bunch of calculations */
  35.         d=(23423423+2394823/234763287*3276472364/2347632+23876322-123123)/2372;
  36. }
  37. /* Or should I so some other busywork, as this tests FPU's more than CPU */
  38. /* But what kind of busy work?  just loop for 1 billion times?  */
  39.  
  40. void io_test()
  41. {
  42.     int i; char c; FILE *tmp;
  43.     tmp=fopen("tmp$$$.tmp","w");            
  44.     for (i=0;i<FILECHARS;i++) putc('a',tmp);     /* Write chars to a file */
  45.     fclose(tmp);
  46.     tmp=fopen("tmp$$$.tmp","r");
  47.     for (i=0;i<51200;i++) c=getc(tmp);           /* Read chars from a file */
  48.     fclose(tmp);
  49. }
  50.  
  51. All these tests take a certain amount of time (around 10 secs each on my
  52. system).  Are these all good or is there too much overhead in either "C"
  53. or basic system architecture to make these busywork tests invalid?
  54. -- 
  55. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  56. * "What do you mean I don't get to work on time... got nothing better to do." *
  57. * "What do you mean I don't pay my bills... why do you think I'm so broke?"   *
  58. *                       stasica@alumni.cs.Colorado.EDU                        *
  59.