The MCFClass Project
Compile-time switches in OPTUtils.h

These macros control how the classes OPTTimers and OPTrand are implemented; choose the appropriate value for your environment, or program a new version if no value suits you. More...

Macros

#define OPT_TIMERS   5
 The class OPTtimers is defined below to give an abstract interface to the different timing routines that are used in different platforms.
 
#define OPT_RANDOM   1
 The class OPTrand is defined below to give an abstract interface to the different random generators that are used in different platforms.
 

Detailed Description

These macros control how the classes OPTTimers and OPTrand are implemented; choose the appropriate value for your environment, or program a new version if no value suits you.

Also, namespaces can be eliminated if they create problems.

Macro Definition Documentation

◆ OPT_TIMERS

#define OPT_TIMERS   5

The class OPTtimers is defined below to give an abstract interface to the different timing routines that are used in different platforms.

This is needed since time-related functions are one of the less standard parts of the C[++] library. The value of the OPT_TIMERS constant selects among the different timing routines:

  • 1 = Use the Unix times() routine in sys/times.h
  • 2 = As 1 but uses sys/timeb.h (typical for Microsoft(TM) compilers)
  • 3 = Still use times() of sys/times.h, but returns wallclock time rather than CPU time
  • 4 = As 3 but uses sys/timeb.h (typical for Microsoft(TM) compilers)
  • 5 = return the user time obtained with ANSI C clock() function; this may result in very accurate time measures, but may be limited to about 72 hours on systems where ints are 32bits.
  • 6 = Use the Unix gettimeofday() routine of sys/time.h; note that this returns wallclock time rather than CPU time
  • 7 = Use the ANSI C routine time() of time.h; note that this returns wallclock time rather than CPU time

Any unsupported value would simply make the class to report constant zero as the time.

◆ OPT_RANDOM

#define OPT_RANDOM   1

The class OPTrand is defined below to give an abstract interface to the different random generators that are used in different platforms.

This is needed since random generators are one of the less standard parts of the C[++] library. The value of the OPT_RANDOM constant selects among the different timing routines:

  • 0 = an hand-made implementation of a rather good random number generator is used; note that this assumes that long ints >= 32 bits
  • 1 = standard rand() / srand() pair, common to all C libraries but not very sophisticated
  • 2 = drand48() / srand48(), common on Unix architectures and pretty good.

Any unsupported value would simply make the functions to report constant zero, which is not nice but useful to quickly fix problems if you don't use random numbers at all.