home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dax1.exe / CLIENT / STRESS / DOS / STRESS.C < prev   
Text File  |  1992-07-15  |  7KB  |  172 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. //   ║              Network C for DOS v2.0                                ║
  8. //   ║              NetWare C Interface DOS v1.2                          ║
  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   02/28/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 "h/appl.h"
  32. #include "dap/dapapi.h"
  33.  
  34. #include <nxt.h>
  35.  
  36. static  DAPDATA *dd;
  37.  
  38. //
  39. //  The atexitproc() is called if the application terminates.  All we'll do
  40. //  here is perform a graceful shutdown... i.e. logout of the Engine
  41. //
  42.  
  43. atexitproc()
  44. {
  45.         if( dd ){
  46.             DAPDeAllocateSession(dd);
  47.             DAPDeInitialize(dd);
  48.         }
  49. }
  50.  
  51. //
  52. //  errorexit() is called if an error is detected on a session.  It calls
  53. //  the internal Debug API DAPDisplaySessionData, which creates a debug
  54. //  file containing relevant info about the session when it failed. i.e. state
  55. //
  56.  
  57. errorexit(int rc, char *msg)
  58. {
  59.     printf("\n\n\t%s. rc = %d\n\tERROR: %s\n",
  60.            msg,
  61.            rc,
  62.            DAPTranslateReturnCode(rc));
  63.     DAPDisplaySessionData(dd);
  64.     exit(1);
  65. }
  66.  
  67. #define DEFOUTER    1000
  68. #define DEFINNER    10
  69.  
  70. main(int argc, char *argv[])
  71. {
  72.         int     rc;
  73.         long    x,y,z,oldval;
  74.         WORD    imStart, imStop;
  75.         LONG    iter=0L;
  76.         LONG    outerlimit = DEFOUTER;
  77.         LONG    innerlimit = DEFINNER;
  78.         char    *transform = "\r\t\t\t\t\t%s\r";
  79.  
  80.         if( argc == 3 ){
  81.             outerlimit = atoi(argv[1]);
  82.             innerlimit = atoi(argv[1]);
  83.         }
  84.         atexit(atexitproc);
  85.         if( (dd = DAPInitialize(SERVERNAME, SERVERTYPE)) == NULL ){
  86.             printf("Could not initialize DAP\n");
  87.             exit(1);
  88.         }
  89.         printf("Initialized okay...\n");
  90.         if( (rc = DAPAllocateSession(dd)) != NULL ){
  91.             errorexit(rc,"Allocate Session failed");
  92.         }
  93.         printf("Attached to server '%s', type '%x'...\n",SERVERNAME,SERVERTYPE);
  94.         imStart = IPXGetIntervalMarker();
  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.                 ++iter;
  157.                 // printf("\r\t\t\t%ld\r",++iter);
  158.             }
  159.         }
  160.         imStop = IPXGetIntervalMarker();
  161.         if( (rc = DAPDeAllocateSession(dd)) != NULL ){
  162.             errorexit(rc,"De Allocate Request failed");
  163.         }
  164.         printf("Detached from server...\n");
  165.         DAPDeInitialize(dd);
  166.         dd = NULL;
  167.         printf("DeInitialized okay...\n");
  168.         printf("%ld total operations performed\n",iter*6);
  169.         printf("%u - %u = %u ticks, %u secs\n",imStop, imStart, imStop - imStart, (imStop - imStart)/18);
  170.         return 0;
  171. }
  172.