4 ms·
To start, you can instrument the loop using a function like clock_gettime(CLOCK_MONOTONIC, ...)[0], or you can compile with the -pg flag and use gprof[1]. If y
by nitrogen 13y ago
To start, you can instrument the loop using a function like clock_gettime(CLOCK_MONOTONIC, ...)[0], or you can compile with the -pg flag and use gprof[1]. If you instrument, put your instrumentation outside the loop and divide by the number of iterations. From there you can start researching tools like valgrind (and its different internal modules like cachegrind, helgrind, etc.), OProfile, and others.
Your available tools will be different once you start using CUDA or OpenCL; you'll need to look for profiling methods designed for those environments at that point.
[0] http://man.cx/clock_gettime http://man.cx/clock_gettime
[1] https://duckduckgo.com/?q=gprof+tutorial https://duckduckgo.com/?q=gprof+tutorial