home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / F0 < prev    next >
Encoding:
Text File  |  1992-06-07  |  3.5 KB  |  81 lines

  1. #ifndef __RWBENCH_H__
  2. #define __RWBENCH_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWBench:  A class to help in the running of benchmarks
  7.  *
  8.  * $Header:   E:/vcs/rw/bench.h_v   1.2   17 Mar 1992 11:31:22   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave Software, Inc.
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  *
  16.  * Copyright (C) 1992. This software is subject to copyright 
  17.  * protection under the laws of the United States and other countries.
  18.  *
  19.  ***************************************************************************
  20.  *
  21.  * To use, derive a class from RWBench including a doLoop(unsigned long) 
  22.  * function, and a what() function (if you plan to use report()).  
  23.  * The doLoop(unsigned long N) function should perform N operations of
  24.  * the type you are trying to benchmark.  RWBench will call this function
  25.  * over and over again until "duration" time has elapsed.  Then it will sum
  26.  * the total number of operations performed.
  27.  *
  28.  * To run, construct an object then call go().  Then call report() to get
  29.  * a summary.  You can call ops() outerLoops(), etc. for more detail.
  30.  *
  31.  * If you wish to correct for overhead, then provide an idleLoop() function
  32.  * which does non-benchmark related calculations.
  33.  *
  34.  ***************************************************************************
  35.  *
  36.  * $Log:   E:/vcs/rw/bench.h_v  $
  37.  * 
  38.  *    Rev 1.2   17 Mar 1992 11:31:22   KEFFER
  39.  * 
  40.  *    Rev 1.0   10 Feb 1992 18:54:06   KEFFER
  41.  * Initial revision.
  42.  */
  43.  
  44. #include "rw/timer.h"
  45.  
  46. class RWExport RWBench {
  47.  
  48. public:
  49.  
  50.   // Default: 5 second test, one inner loop op, no machine name.
  51.   RWBench(double duration = 5, unsigned long ILO=1000, const char* machine = 0);
  52.   virtual void   parse(int argc, char* argv[]);
  53.   virtual void   go();                      // Run the benchmark
  54.   virtual void   doLoop(unsigned long n)=0; // User supplied: should execute the inner loop n times
  55.   virtual void   idleLoop(unsigned long n); // To calculate looping overhead
  56.   virtual void   what(ostream&) const;      // Print out what we're doing --- used by report()
  57.   void           where(ostream&) const;     // Print out the machine type and the compiler
  58.   virtual void   report(ostream&) const;    // Print out #reps and speed
  59.   double         setDuration(double);       // Set test duration to something else
  60.   unsigned long  setInnerLoops(unsigned long);// Set # inner loops to something else
  61.   double         duration() const           {return _timeToTest;}
  62.   unsigned long  innerLoops() const         {return _innerLoops;}
  63.   double         time() const;              // time to execute in seconds
  64.   unsigned long  outerLoops() const;        // Number of times the inner loop was executed
  65.   double         ops() const;               // Number of operations performed
  66.   double         opsRate() const;           // Number of operations per second
  67.   double         kiloOpsRate() const;       // Number of thousands of ops per second
  68.   double         megaOpsRate() const;       // Number of millions of ops per second
  69.  
  70. private:
  71.  
  72.   const char*    _machine;       // What machine we're running on
  73.   double         _timeToTest;    // How long should the test take
  74.   unsigned long  _innerLoops;    // Number of inner loop operations to be done
  75.   unsigned long  _outerLoops;    // Number of outer loops actually executed
  76.   double         _delta;         // Actual time (corrected for overhead)
  77. };
  78.  
  79. pragma pop_align_members();
  80. #endif    /* __RWBENCH_H__ */
  81.