Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ep:labs:07:contents:tasks:ex2 [2025/05/05 00:38]
radu.mantu
ep:labs:07:contents:tasks:ex2 [2025/05/05 00:58] (current)
radu.mantu
Line 51: Line 51:
  
 Add a [[https://​gcc.gnu.org/​onlinedocs/​gcc-4.7.0/​gcc/​Function-Attributes.html|destructor]] to the instrumentation callback library in which you will display these statistics when the program terminates. Add a [[https://​gcc.gnu.org/​onlinedocs/​gcc-4.7.0/​gcc/​Function-Attributes.html|destructor]] to the instrumentation callback library in which you will display these statistics when the program terminates.
 +
 +<note tip>
 +If you are working natively on Linux, consider using the **rdtsc** macro from ''​util.h''​. This is a wrapper over the [[https://​www.felixcloutier.com/​x86/​rdtsc|RDTSC]] instruction and it's the most efficient method of calculating the elapsed time. You can find a usage example [[https://​github.com/​RaduMantu/​tsn-keysight/​blob/​master/​src/​slice.c#​L22|here]]. Keep in mind that your CPU increments this timestamp counter a fixed number of times per second. This frequency is also the //base frequency// of your CPU. You can find it expressed in kHz in ''/​sys/​devices/​system/​cpu/​cpu0/​cpufreq/​base_frequency''​.
 +
 +If you are working inside a VM or simply don't want to use **rdtsc**, use [[https://​linux.die.net/​man/​3/​clock_gettime|clock_gettime()]] instead. Choose a //monotonic timer// that fits your needs. Check each timer'​s resolution and explain why it matters.
 +</​note>​
ep/labs/07/contents/tasks/ex2.1746394681.txt.gz ยท Last modified: 2025/05/05 00:38 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0