midrange.com code scratchpad
Name:
BENCH.C
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
02/16/2015 05:07:06 pm
IP:
Logged
Description:
CPU Speed Benchmark written in C (Compile with CRTBNDC or CRTBNDCPP)
Code:
  1. #include <time.h>
  2. #include <stdio.h>
  3.  
  4. void main ( ) {
  5.   time_t startTime, endTime;
  6.   int    jx, ix, bx, loopCx ;
  7.  
  8.   loopCx        = 5000000 ;
  9.   jx            = 0 ;
  10.   time(&startTime);
  11.   for (bx = 1 ; bx <= 20 ; ++bx) {
  12.      for (ix = 1 ; ix <= loopCx ; ++ix ) {
  13.         jx += ix ;
  14.         if (jx > 45000000)
  15.            jx = 0 ;
  16.         }
  17.      }
  18.   time(&endTime);
  19.   printf("Started at %s\n", asctime(gmtime(&startTime)));
  20.   printf("Ended   at %s\n", asctime(gmtime(&endTime)));
  21.   printf("... Press Enter to exit program ...\n");
  22.   fflush(stdin);
  23.   getchar();
  24.   }
  25.  
  26.  
© 2004-2019 by midrange.com generated in 0.005s valid xhtml & css