perf has perf stat to count events (cycles, instructions, context switches) and perf record plus perf report to sample stacks over time. Sampling costs less than tracing every call, and the samples can be drawn as a flame-graph.