Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
user_guide:extend:profiling [2019/01/30 14:44] – deleted artefact from move operation (i think). current page at user_guide:extend:profiling oroehrig | user_guide:extend:profiling [2019/01/30 14:44] (current) – old revision restored (2019/01/29 21:46) oroehrig | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Profiling | ||
+ | |||
+ | This page describes two different ways how you can analyze and profile your code in '' | ||
+ | |||
+ | |||
+ | ==== using valgrind ==== | ||
+ | |||
+ | Using the tool [[http:// | ||
+ | Once valgrind is installed on your system you are able to use many analyzing tools, as callgrind and cachegrind. | ||
+ | You will find more details in the [[http:// | ||
+ | |||
+ | You can run '' | ||
+ | < | ||
+ | valgrind --tool=callgrind perl/ | ||
+ | </ | ||
+ | or your corresponding path to '' | ||
+ | |||
+ | '' | ||
+ | But be aware that this will slow down your program, such that you should just test your code with very small examples. | ||
+ | |||
+ | A typical shell output looks like this: | ||
+ | |||
+ | < | ||
+ | ==30738== Callgrind, a call-graph generating cache profiler | ||
+ | ==30738== Copyright (C) 2002-2009, and GNU GPL'd, by Josef Weidendorfer et al. | ||
+ | ==30738== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info | ||
+ | ==30738== Command: perl/ | ||
+ | |||
+ | ==30738== | ||
+ | ==30738== For interactive control, run ' | ||
+ | Welcome to polymake version 2.12.3, rev. 11104 [DEVELOPER MODE] | ||
+ | Copyright (c) 1997-2012 | ||
+ | Ewgenij Gawrilow, Michael Joswig (TU Darmstadt) | ||
+ | http:// | ||
+ | |||
+ | This is free software licensed under GPL; see the source for copying conditions. | ||
+ | There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
+ | |||
+ | Press F1 or enter ' | ||
+ | |||
+ | Application polytope currently uses following third-party software packages: | ||
+ | cddlib, geomview, graphviz, jreality, lrslib, nauty, normaliz2, permlib, povray, qhull, sketch, sympol, tosimplex | ||
+ | For more details: | ||
+ | polytope > script(" | ||
+ | polytope > exit; | ||
+ | ==30738== | ||
+ | ==30738== Events | ||
+ | ==30738== Collected : 2091660153168 | ||
+ | ==30738== | ||
+ | ==30738== I | ||
+ | </ | ||
+ | |||
+ | After closing '' | ||
+ | |||
+ | Picture1 | ||
+ | |||
+ | In our example you can see from this file, that mostly called is the interior function '' | ||
+ | This gives the hint that many Linear Programs will be solved that nearly all time is needed for that. | ||
+ | | ||
+ | |||
+ | Another useful tool is cachegrind. You can run your code similar to the above via the command | ||
+ | < | ||
+ | valgrind --tool=cachegrind perl/ | ||
+ | </ | ||
+ | you will produce a file called cachegrind.out.* and also the shell output is similar. | ||
+ | The data you will get tells you about the cach misses in your Program. | ||
+ | |||
+ | A weak point of this methode is that also other information than your code is analyzed, as recompiling and the files which where execute by the start of | ||
+ | '' | ||
+ | |||
+ | |||
+ | |||
+ | ==== using gprof ==== | ||
+ | Another way is using [[http:// | ||
+ | |||
+ | You can change compiler flags in the file '/ | ||
+ | It should look like this (with your corresponding paths): | ||
+ | < | ||
+ | ... | ||
+ | Cflags := -march=native -g -pg -Wall -I/ | ||
+ | CXXflags := -march=native -g -pg -ftemplate-depth-200 -Wall -Wno-strict-aliasing -Wno-parentheses -fno-inline-functions-called-once -I/ | ||
+ | ... | ||
+ | CXXOPT := -O2 | ||
+ | ... | ||
+ | LDflags := -g -pg -L/ | ||
+ | LDsharedFlags := -shared -O2 -g -pg -L/ | ||
+ | LDcallableFlags := -shared -O2 -g -pg -L/ | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | For this version of '' | ||
+ | < | ||
+ | ./test | ||
+ | </ | ||
+ | This takes a while and produces the file ' | ||
+ | < | ||
+ | gprof [executable file] [> Outfile] | ||
+ | </ | ||
+ | |||
+ | |||