title: Using Time stamp counter to get the time stamp
body: <p>I have used the below code to get the clock cycle of the processor</p>
  
  <pre class="lang-c prettyprint-override"><code>unsigned long long rdtsc(void)
  {
    unsigned hi, lo;
    __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
    return ( (unsigned long long)lo)|( ((unsigned long long)hi)&lt;&lt;32 );
  }
  </code></pre>
  
  <p>I get some value say 43, but what is the unit here? Is it in microseconds or nanoseconds.</p>
  
  <p>I used below code to get the frequency of my board.</p>
  
  <pre><code>cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
  1700000
  </code></pre>
  
  <p>I also used below code to find my processor speed</p>
  
  <pre><code>dmidecode -t processor | grep "Speed"
  Max Speed: 3700 MHz
  Current Speed: 3700 MHz
  </code></pre>
  
  <p>Now how do I use above frequency and convert it to microseconds or milliseconds?</p>