Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWBench

Module:  Essential Tools Module   Group:  Miscellaneous Classes


Does not inherit

Local Index

Members

Synopsis

#include <rw/bench.h>
(Abstract base class)

Description

This is an abstract class that can automate the process of benchmarking a piece of code. To use it, derive a class from RWBench, including a definition for the virtual function doLoop(unsigned long N). This function should perform N operations of the type that you are trying to benchmark. RWBench will call doLoop() over and over again until a preset amount of time has elapsed. It will then sum the total number of operations performed.

To run, construct an instance of your derived class and then call go(). Then call report() to get a standard summary. For many compilers, this summary will automatically include the compiler type and memory model. You can call ops(), outerLoops(), etc. for more detail.

If you wish to correct for overhead, then provide an idleLoop() function which should do all non-benchmark-related calculations.

Persistence

None

Example

This example compares string parsing operations by benchmarking a brute force approach versus using RWCString.

Program Output:

Public Constructors

RWBench(double duration = 5, unsigned long ILO=1000,
        const char* machine = 0);

Public Member Functions

virtual void
doLoop(unsigned long N)=0;
double
duration() const;
virtual void
go();
virtual void
idleLoop(unsigned long N);
const char *
machine();
virtual void
parse(int argc, char* argv[]);
void
parse(const char *);
virtual void
report(std::ostream&) const;
double
setDuration(double t);
unsigned long
setInnerLoops(unsigned long N);
virtual void
what(std::ostream&) const;
void
where(std::ostream&) const;
unsigned long
innerLoops() const;
double
time() const;
unsigned long
outerLoops() const;
double
ops() const;
double
opsRate() const;


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.