code: function docker_calcCPUPercent(cpu_stats, precpu_stats) {
    /**
     * @namespace
     * @property {object}  cpu_usage
     * @property {number}  cpu_usage.total_usage
     * @property {number}  system_cpu_usage
     * @property {object}  cpu_usage
     * @property {Array}  cpu_usage.percpu_usage
     */
  
    if (!_windows) {
      let cpuPercent = 0.0;
      // calculate the change for the cpu usage of the container in between readings
      let cpuDelta = cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage;
      // calculate the change for the entire system between readings
      let systemDelta = cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage;
  
      if (systemDelta > 0.0 && cpuDelta > 0.0) {
        // calculate the change for the cpu usage of the container in between readings
        cpuPercent = (cpuDelta / systemDelta) * cpu_stats.cpu_usage.percpu_usage.length * 100.0;
      }
  
      return cpuPercent;
    } else {
      let nanoSecNow = util.nanoSeconds();
      let cpuPercent = 0.0;
      if (_docker_last_read > 0) {
        let possIntervals = (nanoSecNow - _docker_last_read); //  / 100 * os.cpus().length;
        let intervalsUsed = cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage;
        if (possIntervals > 0) {
          cpuPercent = 100.0 * intervalsUsed / possIntervals;
        }
      }
      _docker_last_read = nanoSecNow;
      return cpuPercent;
    }
  }
docs: -------------------------- helper functions for calculation of docker stats