How to profile a pipeline job?

Problem to solve

I want to track a job’s resource usage, since it might become an issue if unchecked.

Steps to reproduce

I’ve tried using docker stats as you can see here:

But it doesn’t actually show the cpu usage whilst running. I tried creating a background while loop, but it’s again too slow to capture any detail.

I figured it out using sys/fs/cgroup/cpu.stat for CPU usage counts.