https://pypi.org/project/pytest-profiling/ Since pytest-profiling is only 150 loc, so we might copy pieces into our own test framework rather than dive into pytest: https://github.com/man-group/pytest-plugins/blob/master/pytest-profiling/pytest_profiling.py
The fix for bug 756199 should lead to a noticeable difference in profiling data for lib/portage/tests/resolver/test_merge_order.py cases that involve circular dependencies.