home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dax1.exe / CLIENT / STRESS / WIN / STRESS.C next >
Text File  |  1992-07-15  |  7KB  |  170 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      stress.c                                              ║
  4. //   ║ abstract:    This module is a stress tester for the DAX Engine.    ║
  5. //   ║                                                                    ║
  6. //   ║ environment: NetWare 3.x v3.11                                     ║
  7. //   ║              Borland C++ 3.0                                       ║
  8. //   ║              NetWare C Interface Windows v1.3                      ║
  9. //   ║                                                                    ║
  10. //   ║  This software is provided as is and carries no warranty           ║
  11. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  12. //   ║  warranties of merchantability, title and fitness for a particular ║
  13. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  14. //   ║  your requirements or that the software is without defect or error ║
  15. //   ║  or that operation of the software will be uninterrupted.  You are ║
  16. //   ║  using the software at your risk.  The software is not a product   ║
  17. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  18. //   ║                                                                    ║
  19. //   ╟────────────────────────────────────────────────────────────────────╢
  20. //   ║ maintenance history:                                               ║
  21. //   ║ level    date      pi   description                                ║
  22. //   ╟────────────────────────────────────────────────────────────────────╢
  23. //   ║  001   07/14/92    kl   initial release.                           ║
  24. //   ╚════════════════════════════════════════════════════════════════════╝
  25.  
  26. #include <stdio.h>
  27. #include <conio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30.  
  31. #include <windows.h>
  32. #include "h/appl.h"
  33. #include "dap/dapapi.h"
  34.  
  35. #include <nxt.h>
  36.  
  37. static  DAPDATA *dd;
  38.  
  39. //
  40. //  The atexitproc() is called if the application terminates.  All we'll do
  41. //  here is perform a graceful shutdown... i.e. logout of the Engine
  42. //
  43.  
  44. void    atexitproc()
  45. {
  46.         if( dd ){
  47.             DAPDeAllocateSession(dd);
  48.             DAPDeInitialize(dd);
  49.         }
  50. }
  51.  
  52. //
  53. //  errorexit() is called if an error is detected on a session.  It calls
  54. //  the internal Debug API DAPDisplaySessionData, which creates a debug
  55. //  file containing relevant info about the session when it failed. i.e. state
  56. //
  57.  
  58. errorexit(int rc, char *msg)
  59. {
  60.     printf("\n\n\t%s. rc = %d\n\tERROR: %s\n",
  61.            msg,
  62.            rc,
  63.            DAPTranslateReturnCode(rc));
  64.     DAPDisplaySessionData(dd);
  65.     exit(1);
  66. }
  67.  
  68. #define DEFOUTER    1000
  69. #define DEFINNER    10
  70.  
  71. main(int argc, char *argv[])
  72. {
  73.         int     rc;
  74.         long    x,y,z,oldval;
  75.         WORD    imStart, imStop;
  76.         LONG    iter=0L;
  77.         LONG    outerlimit = DEFOUTER;
  78.         LONG    innerlimit = DEFINNER;
  79.         char    *transform = "\r\t\t\t\t\t%s\r";
  80.  
  81.         if( argc == 3 ){
  82.             outerlimit = atoi(argv[1]);
  83.             innerlimit = atoi(argv[1]);
  84.         }
  85.         atexit(atexitproc);
  86.         if( (dd = DAPInitialize(SERVERNAME, SERVERTYPE)) == NULL ){
  87.             printf("Could not initialize DAP\n");
  88.             exit(1);
  89.         }
  90.         printf("Initialized okay...\n");
  91.         if( (rc = DAPAllocateSession(dd)) != NULL ){
  92.         errorexit(rc,"Allocate Session failed");
  93.         }
  94.         printf("Attached to server '%s', type '%x'...\n",SERVERNAME,SERVERTYPE);
  95.         for(x=0; !kbhit() && x < outerlimit; ++x){
  96.             for(y=1; !kbhit() && y < innerlimit; ++y){
  97.                 if( (rc = DAPAddOperands(dd,x,y,&z)) != NULL ){
  98.                     if( DAP_CRITICAL_ERROR(rc) ){
  99.                         errorexit(rc,"Add Request failed");
  100.                     }
  101.                     else{
  102.                         printf(transform,DAPTranslateReturnCode(rc));
  103.                     }
  104.                 }
  105.                 if( x + y != z ) printf("%ld + %ld = %ld?\n",x,y,z);
  106.  
  107.                 if( (rc = DAPSubtractOperands(dd,x,y,&z)) != NULL ){
  108.                     if( DAP_CRITICAL_ERROR(rc) ){
  109.                         errorexit(rc,"Subtract Request failed");
  110.                     }
  111.                     else{
  112.                         printf(transform,DAPTranslateReturnCode(rc));
  113.                     }
  114.                 }
  115.                 if( x - y != z ) printf("%ld - %ld = %ld?\n",x,y,z);
  116.  
  117.                 if( (rc = DAPMultiplyOperands(dd,x,y,&z)) != NULL ){
  118.                     if( DAP_CRITICAL_ERROR(rc) ){
  119.                         errorexit(rc,"Multiply Request failed");
  120.                     }
  121.                     else{
  122.                         printf(transform,DAPTranslateReturnCode(rc));
  123.                     }
  124.                 }
  125.                 if( x * y != z ) printf("%ld * %ld = %ld?\n",x,y,z);
  126.  
  127.                 if( (rc = DAPDivideOperands(dd,x,y,&z)) != NULL ){
  128.                     if( DAP_CRITICAL_ERROR(rc) ){
  129.                         errorexit(rc,"Divide Request failed");
  130.                     }
  131.                     else{
  132.                         printf(transform,DAPTranslateReturnCode(rc));
  133.                     }
  134.                 }
  135.                 if( x / y != z ) printf("%ld / %ld = %ld?\n",x,y,z);
  136.  
  137.                 if( (rc = DAPStoreValue(dd,z,&oldval)) != NULL ){
  138.                     if( DAP_CRITICAL_ERROR(rc) ){
  139.                         errorexit(rc,"Store Value failed");
  140.                     }
  141.                     else{
  142.                         printf(transform,DAPTranslateReturnCode(rc));
  143.                     }
  144.                 }
  145.                 oldval = z;     // remember z, and see if it comes back ok
  146.                 if( (rc = DAPRecallValue(dd,&z)) != NULL ){
  147.                     if( DAP_CRITICAL_ERROR(rc) ){
  148.                         errorexit(rc,"Recall Value failed");
  149.                     }
  150.                     else{
  151.                         printf(transform,DAPTranslateReturnCode(rc));
  152.                     }
  153.                 }
  154.                 if( z != oldval ) printf("%ld != %ld?\n",z,oldval);
  155.  
  156.                 if( ++iter % 100 == 0 ) printf("%ld loop iterations completed so far...\n",iter);
  157.             }
  158.         }
  159.         if( (rc = DAPDeAllocateSession(dd)) != NULL ){
  160.             errorexit(rc,"De Allocate Request failed");
  161.         }
  162.         printf("Detached from server...\n");
  163.         DAPDeInitialize(dd);
  164.         dd = NULL;
  165.         printf("DeInitialized okay...\n");
  166.         printf("%ld total operations performed\n",iter*6);
  167.         printf("%u - %u = %u ticks, %u secs\n",imStop, imStart, imStop - imStart, (imStop - imStart)/18);
  168.         return 0;
  169. }
  170.