Question: What method do you use when you want to get performance data about specific code paths?

Answer: 
Well, I have two code snippets. In [pseudocode](http://en.wikipedia.org/wiki/Pseudocode) they are looking like (it's a simplified version, I'm using [QueryPerformanceFrequency](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644905%28v=vs.85%29.aspx) actually):

### First snippet:

```
Timer timer = new Timer
timer.Start

```

### Second snippet:

```
timer.Stop
show elapsed time

```

A bit of hot-keys kung fu, and I can say how much time this piece of code stole from my CPU.
I wrote a simple cross-platform class called [nanotimer](http://www.plflib.org/nanotimer.htm) for this reason. The goal was to be as lightweight as possible so as to not interfere with actual code performance by adding too many instructions and thereby influencing the instruction cache. It is capable of getting microsecond accuracy across windows, mac and linux (and probably some unix variants).

Basic usage:

```
plf::timer t;
timer.start();

// stuff

double elapsed = t.get_elapsed_ns(); // Get nanoseconds

```

start() also restarts the timer when necessary. "Pausing" the timer can be achieved by storing the elapsed time, then restarting the timer when "unpausing" and adding to the stored result the next time you check elapsed time.