Making it work: logging and profiling
This handout is tied to the following lecture
10. Making it work: logging and profilingProfilers
Shell
Python
Other
- (most platforms - Memory profiling) valgrind
- (gcc toolchain) gprof
- (C, C++, Fortran - Threaded and Parallel Code) DDT
There is a longer list of profiling tools available on wikipedia list of performance analysis tools and on the hpc2n debugger and profiler tools list.
Code-examples
Logging
Profilers
cprofile_example.pytimeit_example.pyyappi_example.pypy_spy_example.pycustom_profile_example.pykernprof_example.py
Homework assignments
Add logging
This homework assignment concerns implementing logging in a project. My recommendation is to do this for the chat server that you are currently working on in the larger practical. Since logging will be project wide, everyone will need to start using it in their implementations.
Profile a program
For this task you should profile a program that actually takes time to execute and where optimization might be possible. My recommendation is to profile the differential equation integrator from the first practical task and the calculator from one of the homework assignments (it could also be one of your current work projects). Use the profiling results to highlight where the program is bottlenecked.
How we can use these results to optimize the code will be covered in later lectures.