HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
benchmark.h File Reference
#include <iostream>
#include <vector>
#include <OpenImageIO/function_view.h>
#include <OpenImageIO/string_view.h>
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/timer.h>
+ Include dependency graph for benchmark.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Benchmarker
 

Namespaces

 pvt
 

Functions

template<class T >
OIIO_NAMESPACE_BEGIN
OIIO_FORCEINLINE T const
DoNotOptimize (T const &val)
 
OIIO_FORCEINLINE void clobber_all_memory ()
 
void OIIO_API clobber (void *p)
 
OIIO_FORCEINLINE void clobber (const void *p)
 
template<typename T >
OIIO_FORCEINLINE T & clobber (T &p)
 
template<typename FUNC >
double time_trial (FUNC func, int ntrials=1, int nrepeats=1, double *range=NULL)
 
template<typename FUNC >
double time_trial (FUNC func, int ntrials, double *range)
 Version without repeats. More...
 
OIIO_API std::vector< double > timed_thread_wedge (function_view< void(int)> task, function_view< void()> pretask, function_view< void()> posttask, std::ostream *out, int maxthreads, int total_iterations, int ntrials, cspan< int > threadcounts={1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 128})
 
OIIO_API void timed_thread_wedge (function_view< void(int)> task, int maxthreads, int total_iterations, int ntrials, cspan< int > threadcounts={1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 128})
 
void OIIO_API pvt::use_char_ptr (char const volatile *)
 
template<class T >
OIIO_FORCEINLINE T constDoNotOptimize (T const &val)
 

Function Documentation

void OIIO_API clobber ( void p)

A call to clobber(p) fools the compiler into thinking that p (or *p, for the pointer version) might potentially have its memory altered. The implementation actually does nothing, but it's in another module, so the compiler won't know this and will be conservative about any assupmtions of what's in p. This is helpful for benchmarking, to help erase any preconceptions the optimizer has about what might be in a variable.

OIIO_FORCEINLINE void clobber ( const void p)

Definition at line 74 of file benchmark.h.

template<typename T >
OIIO_FORCEINLINE T& clobber ( T &  p)

Definition at line 77 of file benchmark.h.

OIIO_FORCEINLINE void clobber_all_memory ( )

clobber_all_memory() is a helper function for timing benchmarks that fools the compiler into thinking that potentially any part of memory has been modified, and thus serves as a barrier where the optimizer won't assume anything about the state of memory preceding it.

Definition at line 480 of file benchmark.h.

template<class T >
OIIO_NAMESPACE_BEGIN OIIO_FORCEINLINE T const& DoNotOptimize ( T const val)

DoNotOptimize(val) is a helper function for timing benchmarks that fools the compiler into thinking the the location 'val' is used and will not optimize it away. For benchmarks only, do not use in production code! May not work on all platforms. References:

Definition at line 455 of file benchmark.h.

template<class T >
OIIO_FORCEINLINE T const& DoNotOptimize ( T const val)

DoNotOptimize(val) is a helper function for timing benchmarks that fools the compiler into thinking the the location 'val' is used and will not optimize it away. For benchmarks only, do not use in production code! May not work on all platforms. References:

Definition at line 455 of file benchmark.h.

template<typename FUNC >
double time_trial ( FUNC  func,
int  ntrials = 1,
int  nrepeats = 1,
double *  range = NULL 
)

Helper template that runs a function (or functor) n times, using a Timer to benchmark the results, and returning the fastest trial. If 'range' is non-NULL, the range (max-min) of the various time trials will be stored there.

DEPRECATED(1.8): This may be considered obsolete, probably the Benchmarker class is a better solution.

Definition at line 329 of file benchmark.h.

template<typename FUNC >
double time_trial ( FUNC  func,
int  ntrials,
double *  range 
)

Version without repeats.

Definition at line 353 of file benchmark.h.

OIIO_API std::vector<double> timed_thread_wedge ( function_view< void(int)>  task,
function_view< void()>  pretask,
function_view< void()>  posttask,
std::ostream *  out,
int  maxthreads,
int  total_iterations,
int  ntrials,
cspan< int threadcounts = {1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 128} 
)
OIIO_API void timed_thread_wedge ( function_view< void(int)>  task,
int  maxthreads,
int  total_iterations,
int  ntrials,
cspan< int threadcounts = {1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 128} 
)