GitXplorerGitXplorer
k

function_timer

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
637531303c18246c54781999388cdc368abee745

1. added cxx-11 requirement to test.cpp

kkvedala committed 5 years ago
Verified
034f0fac73e93055bfbff2f771c7ab77cf510e44

remove clang=6

kkvedala committed 5 years ago
Verified
7d3417d391430069ac4aec29c19cdcd59600f6b8

remove sudo

kkvedala committed 5 years ago
Verified
6e5f134e8b77b59ca0e470988cd2ec362cadbb38

remove trusty os

kkvedala committed 5 years ago
Verified
9a442f1cc86e0f593086f95bece61d8038da3438

add packages to travis.ci

kkvedala committed 5 years ago
Verified
d6b7b0b157e7b5d0d768751787f197c5fc22f885

use 'trustty' os on travis-ci to support cxx-11

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.