Bridges-C++  3.4.2
Bridges(C++ API)
Public Member Functions | List of all members
bridges::benchmark::SortingBenchmark Class Reference

#include <SortingBenchmark.h>

Detailed Description

Benchmarks sorting algorithm.

Benchmarks sorting algorithms and add time series to a LineChart.

The benchmark goes from an initial size controlled by setBaseSize() to a largest size controlled by setMaxSize(). One can also set a maximum time spent on a particular run using setTimeCap().

The benchmark goes from a array size of n to the next one of geoBase * n + increment, where the base is controlled by setGeometric() and increment is controlled by setIncrement(). For simpler use one can set a purley linear sampling with linearRange() or a purely geometric one with geometricRange().

The sorting algorithms must have for prototype: void (sort)(int array, int arraysize); and can be passed to the run function for being benchmarked. A typical use would look something like

void mysort(int* array, int arraysize);
LineChart lc;
sb.linearRange (100, 1000, 5);
sb.run("mysortingalgorithm", mysort);
SortingBenchmark(LineChart &p)
Definition: SortingBenchmark.h:122
Author
Erik Saule
Date
07/20/2019

Public Member Functions

 SortingBenchmark (LineChart &p)
 
void setGenerator (const std::string &generatorName)
 
std::string getGenerator () const
 
void setMaxSize (int size)
 Puts a cap on the largest array to be used. More...
 
void setBaseSize (int size)
 Smallest array to be used. More...
 
void setIncrement (int inc)
 Sets the increment for the benchmark size. More...
 
void setGeometric (double base)
 Sets a geometric progression for the benchmark size. More...
 
void linearRange (int baseSize, int maxSize, int nbPoint)
 The benchmark will sample a range with a fixed number of points. More...
 
void geometricRange (int baseSize, int maxSize, double base)
 The benchmark will sample a range using in geometrically increasing sequence. More...
 
void setTimeCap (double cap_in_s)
 sets an upper bound to the time of a run. More...
 
void run (std::string algoName, void(*runnable)(int *, int))
 benchmark one implementation More...
 

Constructor & Destructor Documentation

◆ SortingBenchmark()

bridges::benchmark::SortingBenchmark::SortingBenchmark ( LineChart p)
inline

Member Function Documentation

◆ geometricRange()

void bridges::benchmark::SortingBenchmark::geometricRange ( int  baseSize,
int  maxSize,
double  base 
)
inline

The benchmark will sample a range using in geometrically increasing sequence.

The benchmark will sample the range [baseSize; maxSize] using a geometric distribution in base base. That is to say, it will sample baseSize, base*baseSize, base*base*baseSize, ...

Parameters
baseSizelower bound of the range sampled
maxSizeupper bound of the range sampled
basebase of the geometric increase

◆ getGenerator()

std::string bridges::benchmark::SortingBenchmark::getGenerator ( ) const
inline

◆ linearRange()

void bridges::benchmark::SortingBenchmark::linearRange ( int  baseSize,
int  maxSize,
int  nbPoint 
)
inline

The benchmark will sample a range with a fixed number of points.

The benchmark will sample about nbPoint equally distributed in the range [baseSize; maxSize]

Parameters
baseSizelower bound of the range sampled
maxSizeupper bound of the range sampled
nbPointnumber of sample

◆ run()

void bridges::benchmark::SortingBenchmark::run ( std::string  algoName,
void(*)(int *, int)  runnable 
)
inline

benchmark one implementation

Parameters
algoNamescreen name of the algorithm to be used in the visualization
runnablepointer to the sorting function to benchmark

◆ setBaseSize()

void bridges::benchmark::SortingBenchmark::setBaseSize ( int  size)
inline

Smallest array to be used.

Parameters
sizeof the smallest array to use/

◆ setGenerator()

void bridges::benchmark::SortingBenchmark::setGenerator ( const std::string &  generatorName)
inline
Parameters
generatorNamepossible values are "random", "inorder", "reverseorder", "fewdifferentvalues", "almostsorted"

◆ setGeometric()

void bridges::benchmark::SortingBenchmark::setGeometric ( double  base)
inline

Sets a geometric progression for the benchmark size.

Parameters
basenew base of the geometric progression

◆ setIncrement()

void bridges::benchmark::SortingBenchmark::setIncrement ( int  inc)
inline

Sets the increment for the benchmark size.

Parameters
incnew value of the increment

◆ setMaxSize()

void bridges::benchmark::SortingBenchmark::setMaxSize ( int  size)
inline

Puts a cap on the largest array to be used.

Parameters
sizeMaximum size considered

◆ setTimeCap()

void bridges::benchmark::SortingBenchmark::setTimeCap ( double  cap_in_s)
inline

sets an upper bound to the time of a run.

The benchmark will end after a run if it takes more than the given amount of time. So it is possible a particular run takes more than the alloted time, but that will be the last run.

Parameters
cap_in_stime limit in seconds

The documentation for this class was generated from the following file: