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_UTIL_API clobber (void *p)
 
OIIO_FORCEINLINE void clobber (const void *p)
 
template<typename T >
OIIO_FORCEINLINE T & clobber (T &p)
 
template<typename T , typename... Ts>
OIIO_FORCEINLINE void clobber (T &p, Ts &...ps)
 
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_UTIL_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_UTIL_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_UTIL_API pvt::use_char_ptr (char const volatile *)
 
template<class T >
OIIO_FORCEINLINE T constDoNotOptimize (T const &val)
 

Function Documentation

void OIIO_UTIL_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 assumptions 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 49 of file benchmark.h.

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

Definition at line 52 of file benchmark.h.

template<typename T , typename... Ts>
OIIO_FORCEINLINE void clobber ( T &  p,
Ts &...  ps 
)

Definition at line 56 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 465 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 440 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 440 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 313 of file benchmark.h.

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

Version without repeats.

Definition at line 337 of file benchmark.h.

OIIO_UTIL_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_UTIL_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} 
)