SkillAgentSearch skills...

Stopwatch

A POSIX C/C++ Stopwatch Library

Install / Use

/learn @MichaelDipperstein/Stopwatch
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

DESCRIPTION

This archive contains a simple and readable an POSIX C/C++ library providing basic stopwatch functionality. The library attempts to maintain microsecond accuracy for timing, but reports values in milliseconds. The actual accuracy is platform dependent.

Included in this library are two sample programs demonstrating the usage the stopwatch routines on both C and C++.

More information on this library may be found at: https://michaeldipperstein.github.io/stopwatch.html

FILES

COPYING - Rules for copying and distributing GPL software COPYING.LESSER - Rules for copying and distributing LGPL software Makefile - Makefile for this project (assumes gcc compiler and GNU make) README - this file sample.c - Sample program demonstrating usage of C stopwatch routines sample.cpp - Sample program demonstrating usage of C++ stopwatch routines stopwatch.h - Header file containing type definitions, prototypes, and a class definition to be used by programs linking to the stopwatch library stopwatch.h - C source file containing the code that implemets the stopwatch library

BUILDING

To build these files with GNU make and gcc:

  1. Windows users should define the environment variable OS to be Windows or Windows_NT. This is often already done.
  2. Enter the command "make" from the command line.

Two sample programs will be generated, sample and sample_cpp. sample verifies the C version of the stopwatch library. sample verifies the C++ version of the stopwatch library.

C USAGE

The following line declares a stopwatch data structure "stopWatch": stopwatch_t stopWatch;

The following line starts or resets a stopwatch using the data structure "stopWatch": StartTimer(&stopWatch);

The following line returns the number of milliseconds a stopwatch using the data structure "stopWatch" has been running: ReadTimer(&stopWatch);

The following line stops a stopwatch using the data structure "stopWatch" without resetting it: StopTimer(&stopWatch);

The following line restarts a stopwatch using the data structure "stopWatch", nothing will happen if the stopwatch is already running: ResumeTimer(&stopWatch);

C++ USAGE

The following line declares and initializes a stopwatch object "stopWatch": stopwatch_c stopWatch;

The following line starts or resets a stopwatch object "stopWatch": stopWatch.Start();

The following line returns the number of milliseconds a stopwatch object "stopWatch" has been running: stopWatch.Read();

The following line stops a stopwatch object "stopWatch" without resetting it: stopWatch.Stop();

The following line restarts a stopwatch object "stopWatch" nothing will happen if the stopwatch is already running: stopWatch.Resume();

HISTORY

11/07/11 - Initial release 02/08/12 - Replace gettimeofday() with clock_gettime to be resilient to time adjustments.

AUTHOR

Michael Dipperstein (mdipperstein@gmail.com)

Related Skills

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated2y ago
Forks1

Languages

C

Security Score

70/100

Audited on Aug 24, 2023

No findings