GitXplorerGitXplorer
k

function_timer

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
0f62dda134903687ebff6408a1495293e9e3f336

added Travis build badge

kkvedala committed 5 years ago
Verified
4f0370694476210bf6252fd47825e50fd8c3a6dd

Create README.md

kkvedala committed 5 years ago
Verified
fc482b5e6a9b72e1ef4f9bc73535a3878e99d7e9

clang compile fix - travis-ci/travis-ci#8613

kkvedala committed 5 years ago
Verified
8dab6c33e5c7d6c95cf3c16afcfb13cb99b39bf1

remove scientific default in cout

kkvedala committed 5 years ago
Verified
eee57246381389c24a0312bee7b592ea66de32b1

export number of openmp threads

kkvedala committed 5 years ago
Verified
4031343de27c0718898946a1785f9a97c8cb52b4

force only static library

kkvedala committed 5 years ago

README

The README file for this repository.

Build Status

function_timer

A wrapper around the CXX-11's std::chrono library with high-precision timer to measure precise execution times in a program. The wrapper enables direct use in C and C++ programs.

Compile

The module is provided with a cmake build system. The compile sequence is:

mkdir build
cd build
cmake .. [-G <Generator>] [-DCMAKE_INSTALL_PREFIX=<install path>]
cmake --build . --config [Release/Debug]

This builds a static library function_timer that can be installed to the prefix using:

cmake --install .

APIs

The library, though written in C++, provides with C and a C++ interfaces.

C

  1. Include the header file function_timer.h
  2. Create the timer pointer instance
function_timer *timer = new_timer();
  1. Start timer instance
start_timer(timer);
  1. End timer & get the duration since timer start.
double duration = end_timer(timer);

If the end_timer function is called before calling the start_timer, the duration value is not guranteed to be 0 and will be invalid. There will not be any error messages.

  1. Delete the timer instance
delete_timer(timer);

C++

  1. Include the header file function_timer.h
  2. Create the timer pointer instance
function_timer *timer = new function_timer();
// or
function timer;
  1. Start timer instance
timer.start_timer();
  1. End timer & get the duration since timer start.
timer.end_timer();
double duration = timer.get_duration();

If the end_timer function is called before calling the start_timer, the duration value is not guranteed to be 0 and will be invalid. There will not be any error messages.

  1. If instantiated as a pointer, delete the timer instance
delete timer;   // iff timer is a pointer

Examples

Two sample implementations are provided as

  • test.c : test case in C
  • test.cpp : test case in C++

Note

To compile with C++, must enable the CXX-11 standard to account for std::chrono library.