andikleen / pmu-tools

Intel PMU profiling tools
GNU General Public License v2.0
1.97k stars 330 forks source link

How to measure only the second part (a region) of a program? #509

Closed FabianSchuetze closed 6 months ago

FabianSchuetze commented 6 months ago

Thanks for this wonderful repo - it's a pleasure to work with it.

I have a simple program that consists of two functions:

int main() {
    std::vector<float> data = preparation();
    Result res = calculation(data);
}

I am only interested in metrics related to the calculation function. Can I use toplev.py in such cases? If so, how?

I know roughly how long it takes to reach the calculation function. The wiki mentions that command line argument -D and says:

We run this with level toplev, skipping the initialization phase (about 80 ms). This is a useful technique with short programs to get better measurements (I measured the initialization phase before by just printing the time at the top of the program)

However, I do not see the option D listed in the available command line arguments for toplev.py.

andikleen commented 6 months ago

The toplev help only lists the toplev arguments, but it supports any perf arguments too. -D is a perf argument.