3 ms·
Thanks! Is there a good profiling tool you recommend? Right now I'm using time command on Linux. How can I measure the execution time of a single loop inside m
by p1esk 13y ago
Thanks! Is there a good profiling tool you recommend?
Right now I'm using time command on Linux. How can I measure the execution time of a single loop inside my program?
- nitrogen 13y agoTo 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