system-time-monotonic-0.2: Simple library for using the system's monotonic clock

PortabilityTested on Linux and Windows.
Maintainerjoeyadams3.14159@gmail.com
Safe HaskellSafe-Infered

System.Time.Monotonic

Contents

Description

This module provides a platform-independent API for using the system's monotonic clock.

Known issues:

  • On Windows XP, this uses GetTickCount, which has a 49.7 day wraparound. Clock works around this problem, but the workaround only works if clockGetTime is called at least once every 24.8 days.
  • On Linux, this uses clock_gettime with CLOCK_MONOTONIC, which (unfortunately) stops when the computer is suspended. Thus, clockGetTime will not include time spent sleeping. Do not rely on this behavior, as it may be fixed in a future version of this library.

Synopsis

Clock

newClock :: IO ClockSource

Create a new Clock. The result of clockGetTime is based on the time newClock was called.

clockGetTime :: Clock -> IO DiffTimeSource

Return the amount of time that has elapsed since the clock was created with newClock.

Drivers

newClockWithDriver :: SomeSystemClock -> IO ClockSource

Variant of newClock that uses the given driver. This can be used if you want to use a different time source than the default.

newClock = newClockWithDriver =<< getSystemClock

clockDriverName :: Clock -> StringSource

Return a string identifying the time source, such as "clock_gettime(CLOCK_MONOTONIC)" or "GetTickCount".

Utilities