Profiling your code in C++ or Python

(Note: this posts exists more to help me jog my own memory than to serve as a truly useful reference.)

C/C++

Use valgrind to profile, and kcachegrind to visualize.

valgrind --tool=callgrind ./program
kcachegrind callgrind.out.NNNN

python

Use cProfile to profile, and snake to visualize.

python -m cProfile -o out.prof program.py
runsnake out.prof

Multi-monitor gnome panels

Moving gnome panels to a different monitor.

  1. Right-click the panel you wish to move and select “Properties”.
  2. Uncheck the “Expand” option under the “General” tab.
  3. Grab one of the edges of the panel by clicking on the left or right end (top or bottom end for vertical panels).
  4. Drag the bar to the desired screen and position.
  5. Check the “Expand” option in the “Panel Properties” window and click “Close”.

Source

Use ack-grep with an extension type

Search for some contents (‘foo’) only inside files with a specific custom extension (.ice):

ack-grep --type-set ice:match:/.+\\.ice/ --ice 'foo'

Search for whole words: -w.