Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Martin Grabmueller <magr <at> cs.tu-berlin.de>
Subject: Announce: Package rdtsc for reading IA-32 time stamp counters
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Tuesday 2nd January 2007 14:00:03 UTC (over 10 years ago)
Hallo all,

version 1.0 of package rdtsc has just been released.

This small package contains one module called 'Rdtsc.Rdtsc'.

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.

A small program using this library looks like this:

  module Main where
  import Rdtsc.Rdtsc
  main = do
    t1 <- rdtsc
    t2 <- rdtsc
    putStrLn ("Cost of rdtsc (ffi call): " ++ show (t2 - t1))

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 84 cycles.

The documentation for the package is available here:

  http://uebb.cs.tu-berlin.de/~magr/projects/rdtsc/

Download the source using darcs:

  darcs get http://uebb.cs.tu-berlin.de/~magr/darcs/rdtsc/

I would really like to get feedback on this little package, which
already has been quite useful for me.

Have fun and Happy Haskell Hacking in th New Year,
  Martin
 
CD: 4ms