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