From ScorecWiki

Revision as of 15:06, 7 August 2011; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

This page serves as a gateway for information related to computing the elapsed time between two positions in your software.


cycle counting (rdtsc cycle counter)

  • source code
  • precise
  • cpu frequency required
    • get the cpu frequency in MHz with
   cat /proc/cpuinfo | grep -i "cpu MHZ" -m 1 | awk '{print $4}'

example code

   unsigned long long start_time = 0;
   unsigned long long finish_time = 0;
   unsigned long long total_time = 0;
   start_time = rdtsc();
   //do stuff
   finish_time = rdtsc();
   total_time = finish_time - start_time;  
   printf ("It took %.8lf seconds.\n", total_time / CPUFREQ );
  • low cost and high resolution


  • May offer a high resolution than 1 second.
    • MPI_WTick() - query to determine resolution.

getTimeOfDay() and friends (sys/time.h)

  • portable
  • not always precise or accurate
  • may be relatively expensive on IBM BG (compared to cycle counting)

time.h/ctime.h functions

  • Reference
  • Have a higher resolution than 1 second
  • clock function returns elapsed CPU cycles
  • Needs cpu frequency which may be inaccurate on POSIX compilers
Personal tools