jw-pkg/make/profiler-rules-run.mk

85 lines
2.3 KiB
Makefile
Raw Normal View History

# ---- callgrind
clean: clean.callgrind
callgrind: run-prereq
$(RM) -f core.*
valgrind --tool=callgrind $(VALGRIND_OPTS) $(EXE_PATH) $(EXE_ARGS)
callgrind-noinst: run-prereq
$(RM) -f core.*
valgrind --tool=callgrind --callgrind-out-file=$(CALLGRIND_OUT) --instr-atstart=no $(VALGRIND_OPTS) $(EXE_PATH) $(EXE_ARGS)
$(CALLGRIND_OUT): callgrind
kcachegrind: $(CALLGRIND_OUT)
kcachegrind $<
callgrind-startinst:
ps aux | grep callgrind | grep -v "grep\|make\|callgrind_control" | awk '{print $$2}' | xargs callgrind_control --instr=on
callgrind-stopinst:
ps aux | grep callgrind | grep -v "grep\|make\|callgrind_control" | awk '{print $$2}' | xargs callgrind_control --instr=off
callgrind-dump:
ps aux | grep callgrind | grep -v "grep\|make\|callgrind_control" | awk '{print $$2}' | xargs callgrind_control --dump
clean.callgrind:
$(RM) -f $(CALLGRIND_OUT)
# ---- oprofile
clean: clean.oprof
operf: | $(OPROF_OUT_DIR)
$(OPROF_OUT_DIR):
mkdir -p $@
oprof-setup:
echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
oprof-callgraph.txt:
opreport --session-dir $(OPROF_OUT_DIR) --callgraph > $@.tmp
mv $@.tmp $@
oprof-view-callgraph-txt: oprof-callgraph.txt
less -S $<
oprof-callgraph.dot: oprof-callgraph.txt
cat $< | gprof2dot -f oprofile > $@.tmp
mv $@.tmp $@
oprof-callgraph.pdf: oprof-callgraph.dot
dot -Tpdf $< -o $@.tmp
mv $@.tmp $@
oprof-view-callgraph-pdf: oprof-callgraph.pdf
okular $<
oprof-view-callgraph-dot: oprof-callgraph.dot
xdot $<
#operf: operf.txt
#operf.txt:
# operf --session-dir $(OPROF_OUT_DIR) $(PROF_CMD)
#operf-view-txt: operf.txt
# less -S $<
#operf-callgraph.pdf: gmon.out
# operf $(PROF_EXE_PATH) | operf2dot | dot -Tpdf -o $@.tmp
# mv $@.tmp $@
#operf-pdf: operf-callgraph.pdf
clean.oprof:
$(RM) -rf $(OPROF_OUT_DIR) oprof-callgraph.txt oprof-callgraph.pdf oprof-callgraph.dot
# ---- gcov
clean.gcov:
$(RM) -f *.gcda *.gcov
# ---- gprof
clean: clean.gprof
gprof: gprof.txt
gprof.txt:
gprof $(PROF_EXE_PATH) > $@.tmp
mv $@.tmp $@
gprof-view-txt: gprof.txt
less -S $<
gprof-callgraph.pdf: gmon.out
gprof $(PROF_EXE_PATH) | gprof2dot | dot -Tpdf -o $@.tmp
mv $@.tmp $@
gprof-pdf: gprof-callgraph.pdf
gprof-view-callgraph-pdf: gprof-callgraph.pdf
okular $<
clean.gprof:
$(RM) -f gmon.out gprof.txt *.tmp gprof-callgraph.pdf