Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Portable C library for getting monotonic time
C
branch: master

Added clock_get_uint64(), with a preference for RAW or non-RAW.

clock_gettime() solution seems to work fine. Untested on Windows and Mac.
latest commit 2a86107ffa
@ThomasHabets authored
Failed to load latest commit information.
include Added clock_get_uint64(), with a preference for RAW or non-RAW.
src Added clock_get_uint64(), with a preference for RAW or non-RAW.
.gitignore
LICENSE Added license file
Makefile.am
Makefile.am.common Cleaned up a bit of autotools
README Documented that it works on MacOS X
acinclude.m4 BSD compile fix
bootstrap.sh Added bootstrap.sh
configure.ac
libmonotonic_clock.pc.in

README

monotonic_clock/README

  By Thomas Habets <thomas@habets.pp.se> 2010


What
----
Provides access to a clock that always increases at the same rate.
Unlike the system time (e.g. gettimeofday()) this will never decrease.

However, if there's no monotonic clock on your system then this library
will fall back to gettimeofday().

For more information see:
http://blog.habets.pp.se/2010/09/gettimeofday-should-never-be-used-to-measure-time


Portability
-----------
Verified to be working:

Linux        clock_gettime()
OpenBSD      clock_gettime()
Solaris      clock_gettime()
MacOS X      mach_absolute_time()


Using monotonic_clock in a project
----------------------------------
cd /path/to/project
git submodule add http://github.com/ThomasHabets/monotonic_clock.git
git submodule init
git submodule update

Add to configure.ac:
  AC_CONFIG_SUBDIRS([monotonic_clock])
  AC_SEARCH_LIBS([clock_gettime], [rt])

Add to Makefile.am:
  SUBDIRS=monotonic_clock

Add to src/Makefile.am:
  AM_CFLAGS=-I$(top_srcdir)/monotonic_clock/include @AM_CFLAGS@
  myproghere_LDADD=../monotonic_clock/src/libmonotonic_clock.a


--------------------------------------------------------------------------
Send questions/suggestions/patches/rants/0days to synscan@googlegroups.com
Something went wrong with that request. Please try again.