I need to calculate the execution time of a C++ code segment. On solaris I could do this by using hrtime (high resolution timer) and by starting and stopping the timer before and after the particular section of code. How can I do this on Linux? Is there an equivalent of hrtime in Linux? I need nanosecond precision.