Skip to content

Instantly share code, notes, and snippets.

@KirillLykov
Last active January 8, 2020 10:31
Show Gist options
  • Save KirillLykov/8a090963692f205f441cf6d934cab7b7 to your computer and use it in GitHub Desktop.
Save KirillLykov/8a090963692f205f441cf6d934cab7b7 to your computer and use it in GitHub Desktop.
Performance optimization tips & tricks

Performance tips & tricks

Perf tool [1]

# general statistics
perf stat ./main

# per function statistics with graph call
# -fno-omit-frame-pointer fals must be used to see proper call stack!!!
perf record --call-graph lbr --benchmark_min_time=2 ./main
perf report -g 'graph,0.5,caller' -s dso,sym,srcline ./main

Misc

Simple way to pass flags:

clang $(< flags)

Massif

#!/bin/bash
valgrind --tool=massif --depth=$1 --threshold=5 --pages-as-heap=no ./benchmark  --benchmark_min_time=2  --benchmark_filter=*
ms_print  massif.out.xxx > 2.txt

1 [2] (https://www.kdab.com/wp-content/uploads/stories/Linux_perf_for_Qt_developers.pdf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment