Precise timing of machine code with Linux perf
Today I will show how you can utilize Intel LBR (Last Branch Record) feature to do cycle-based timing of the code blocks. But since Skylake additional component was added to LBR entry which received additional field:
With this new field we are able not only to get the branch history, but also to get precise timing in cycles between two taken branches. With every sample we also capture entire LBR stack which might have multiple branch records for the block that we are interested in:
Notice we have samples, but LBR entries for our branch.
Source: easyperf.net