How performance metrics for CPU is calculated in percentage in Rancher?


Could anyone please explain how Rancher is displaying container performance metrics in percentage for CPU?

I got the stats of containers from the stats API. But I have no clue how the CPU usage percentage is calculated.


Most of the numbers returned by stats are raw always increasing counters of bytes read, nanoseconds run, etc… So to get a useful number you need to compare against the previous data point and the time elapsed.