rdtsc: Binding for the rdtsc machine instruction

[ bsd3, foreign-binding, library ] [ Propose Tags ]

This module provides the function rdtsc for accessing the rdtsc machine register on modern IA-32 processors. This is a 64-bit counter which counts the number of processor cycles since the machine has been powered up. Using this instruction, you can make very precise time measurements which are independent of the actual CPU frequency. But note that you can get strange results sometimes on a superscalar processor.

Also note that the Haskell foreign function interface imposes some additional overheads. On my machine, it takes about 950 cycles to call this function twice and to compute the difference, whereas in C the overhead is only about 88 cycles.

[Skip to Readme]
Versions 1.1.1, 1.1.3,,,,
Dependencies base [details]
License LicenseRef-GPL
Author Martin Grabmueller <magr@cs.tu-berlin.de>
Maintainer magr@cs.tu-berlin.de
Category System
Home page http://uebb.cs.tu-berlin.de/~magr/projects/rdtsc/doc/
Uploaded by DonaldStewart at Tue Feb 13 05:06:57 UTC 2007
Distributions LTSHaskell:, NixOS:, Stackage:
Downloads 2517 total (111 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for rdtsc-1.1.1

[back to package description]
* README file for Rdtsc binding

This small Cabal package provides a Haskell binding to the "rdtsc"
machine instruction on modern IA-32 processors.  This instruction can
be used to read the number of cycles since processor startup and gives
very accurate timing information.

** Usage


  runghc Setup.hs configure
  runghc Setup.hs build
  runghc Setup.hs install

for building and installing system-wide, or

  runghc Setup.hs configure --prefix=$HOME/haskell-modules
  runghc Setup.hs build
  runghc Setup.hs install --user

for building and installing in directory $HOME/haskell-modules.

Just import module "System.CPUTime.Rdtsc" into your Haskell file and use

  ghc --make FILENAME

to compile your program.

The "tests" directory contains a small test program for the module and
demonstrates its usage.  There is also a C version for this test
program, to test the overheads of Haskell's FFI.

Happy Haskell hacking,