Cayley
Pseudo-Random Bits from Finite Groups
Enumerations | Functions
Main.cpp File Reference

Main. More...

#include "Includes.h"
#include "uintx_t.h"
#include "Cayley32.h"

Go to the source code of this file.

Enumerations

enum  Task {
  Time, Generate, GenerateEx, GenerateMT,
  None
}
 Task type.
 

Functions

uint64_t CPUTimeInNanoseconds ()
 CPU time in nanoseconds. More...
 
void PrintHelp ()
 Print help. More...
 
void GetParams (int argc, char *argv[], uintx_t &seed, Task &t)
 Get generator parameters from argv. More...
 
template<typename t >
void Generate (const t &rnd, uint64_t nBufSize)
 Write an infinite number of pseudorandom bits to stdout. More...
 
template<typename t >
double Time (const t &rand, uint64_t n)
 Time a PRNG. More...
 
void Time (Cayley32 *pCayley, uint64_t n)
 Time Cayley and the Mersenne Twister. More...
 
int main (int argc, char *argv[])
 Main. More...
 

Function Documentation

◆ CPUTimeInNanoseconds()

uint64_t CPUTimeInNanoseconds ( )

Get CPU time in nanoseconds.

Returns
User CPU time in nanoseconds.

Definition at line 48 of file CPUtime.cpp.

◆ Generate()

template<typename t >
void Generate ( const t &  rnd,
uint64_t  nBufSize 
)

The bitstream is intended to be piped into Dieharder, which requires an arbitrary length bitstream. Dieharder will break the pipe when it has enough data. The output of the PNRG is accumulated in a buffer before being written to stdout.

Parameters
rndA PRNG.
nBufSizeBuffer size in 8-byte blocks.

Definition at line 85 of file Main.cpp.

◆ GetParams()

void GetParams ( int  argc,
char *  argv[],
uintx_t seed,
Task t 
)

Parse the command line arguments for settings.

Parameters
argcNumber of command line arguments.
argvCommand line arguments.
seed[OUT] Seed.
t[OUT] Task.

Definition at line 50 of file Main.cpp.

◆ main()

int main ( int  argc,
char *  argv[] 
)
Parameters
argcNumber of arguments.
argvArguments.
Returns
0 (What could possibly go wrong?)

Definition at line 147 of file Main.cpp.

◆ PrintHelp()

void PrintHelp ( )

Print canned help message to stdout.

Definition at line 28 of file Main.cpp.

◆ Time() [1/2]

template<typename t >
double Time ( const t &  rand,
uint64_t  n 
)

Measure the average number of nanoseconds per bit used by a PRNG.

Parameters
randPseudorandom number generation function.
nNumber of 64-bit words to generate.
Returns
Number of nanoseconds per bit.

Definition at line 110 of file Main.cpp.

◆ Time() [2/2]

void Time ( Cayley32 pCayley,
uint64_t  n 
)

Print to the console the average number of nanoseconds per bit used by Cayley and the Mersenne Twister.

Parameters
pCayleyPointer to an instance of the Cayley32 PRNG.
nNumber of 64-bit words to generate.

Definition at line 126 of file Main.cpp.