Timing library for prototyping performance
The aim of this library is to provide the most accurate timing system to know how long last a function or a portion of code. It is totaly automated and have some several custom behaviour.
Use of 3 different timing methods: RDTSC,RDTSCP or std::chrono. Theses timers can be used in different situations.
RDTSCP timer is only available on at least Pentium III and wait for all previous instruction to be executed aka when the instruction pipeline is empty.
RDTSC timer is only available on at least Pentium III and do not wait for all previous instruction to be executed aka when the instruction pipeline is empty.
std::chrono uses the standard timer , and it is compatible on all platforms.
The API is composed of 5 methods:
timing::addFunction (string name,function pointer to time) : add to test framework the function identified by the name (the name can be any string as it is only used to identify function during results printing)
timing::setTimingFunction : set the method used to calculate the timing
timing::setNumberExecution : set the number of time the function has to be executed
0: RDTSC
1: RDTSCP
2: RDTSC and RDTSCP
3: std::chrono
99: all methods
timing::Execute: execute all function added with addFunction , you can pass an int if needed
Tips: When using RDTSC, RDTSCP or sdt::chrono ?
Exemple of use:
int main(int argc, char **argv) { timing::addFunction("FIB", fibonacci); timing::addFunction("FIB-OPTIM", fibonacciOptim); timing::setTimingFunction(0); timing::setNumberExecution(1); timing::execute(40); timing::CalcResult(); }
Library example :
git clone https://github.com/fflayol/timingperf.git cd timingperf ;this command is optional, it will copy the file performancetiming.hpp to /usr/local/include make install make ./ex1.out