RandomLib  1.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Macros | Functions
RandomTime.cpp File Reference

Timing RandomLib. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <ctime>
#include <sys/time.h>
#include <RandomLib/Random.hpp>
#include <RandomLib/NormalDistribution.hpp>
#include <RandomLib/RandomSelect.hpp>

Go to the source code of this file.

Macros

#define TIME(expr, esttime)
 

Functions

double HighPrecMult ()
 
long long HighPrecTime ()
 
template<typename Random >
void Time (Random &r)
 
int main (int, char **)
 

Detailed Description

Timing RandomLib.

Compile/link with, e.g.,
g++ -I../include -O2 -funroll-loops -o RandomTime RandomTime.cpp ../src/Random.cpp
./RandomTime

See Timing results, for more information.

Copyright (c) Charles Karney (2006-2011) charl.nosp@m.es@k.nosp@m.arney.nosp@m..com and licensed under the MIT/X11 License. For more information, see http://randomlib.sourceforge.net/

Definition in file RandomTime.cpp.

Macro Definition Documentation

#define TIME (   expr,
  esttime 
)
Value:
{ \
long long t1, t2; \
long long c1 = r.Count(); \
size_t m = int(1.e9/esttime+1); \
t1=HighPrecTime(); \
for (size_t j = m; j; --j) { expr; } \
t2=HighPrecTime(); \
std::cout << std::setprecision(1) << std::setw(8) << std::scientific \
<< 0.1*std::floor((t2-t1)*HighPrecMult()*1.0e10/m+0.5) << "ns "; \
std::string cmd(#expr); \
std::string::size_type p; \
p = cmd.find("template "); \
if (p != std::string::npos) cmd = cmd.substr(0,p) + cmd.substr(p+9); \
p = cmd.find(" = "); \
if (p != std::string::npos) cmd = cmd.substr(p + 3); \
p = cmd.find("Random::"); \
if (p != std::string::npos) cmd = cmd.substr(0,p)+cmd.substr(p+8); \
p = cmd.find("std::"); \
if (p != std::string::npos) cmd = cmd.substr(0,p)+cmd.substr(p+5); \
if (cmd[0] == '(') \
cmd = cmd.substr(1,cmd.size()-2); \
std::cout << std::setprecision(1) << std::setw(5) << std::fixed \
<< (r.Count()-c1)/float(m) << "rv" << " per " << cmd << "\n"; \
}
double HighPrecMult()
Definition: RandomTime.cpp:37
RandomCanonical< RandomGenerator > Random
Definition: Random.hpp:135
long long HighPrecTime()
Definition: RandomTime.cpp:46

Definition at line 63 of file RandomTime.cpp.

Referenced by Time().

Function Documentation

double HighPrecMult ( )

Definition at line 37 of file RandomTime.cpp.

long long HighPrecTime ( )

Definition at line 46 of file RandomTime.cpp.

template<typename Random >
void Time ( Random &  r)

Definition at line 89 of file RandomTime.cpp.

References TIME.

int main ( int  ,
char **   
)

Definition at line 173 of file RandomTime.cpp.