GitXplorerGitXplorer
k

function_timer

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
1368ce2b256ece65d81e5e2a4c5d6398703e2184

add C function to end and delete timer

kkvedala committed 5 years ago
Verified
e53e894f52bb1cb57cf7c86d6642e88994e67c71

add function `end_timer_delete`

kkvedala committed 5 years ago
Verified
ddae0860b5bf0e69d4f83922ca23e8a1f466664b

added make policy 0057

kkvedala committed 5 years ago
Verified
e0dc782b7b0f162299d10d94b0132f111d89c22f

minor changes to trigger travis

kkvedala committed 5 years ago
Verified
327ddab3e895c26026eeb39ed7e0b44d82597137

update description

kkvedala committed 5 years ago
Verified
1210af54daf717cf41611f8e21e6548dd4bc01d3

Create LICENSE

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.