• While trying things out for my current power manager app changes, I found this thread and was intrigued by @Gordon 's last edit. Some experimentation lead to:

    const systickMax = peek32(0xE000E014);
    print("Max:", systickMax);
    
    let t, systickNow, tLater, systickLater, systickDiff;
    
    setInterval(() => {
      tLater = Date.now();
      systickLater = peek32(0xE000E018);
    
      systickDiff = systickLater - systickNow;
      if (systickDiff < 0) systickDiff += systickMax;
    
      t = Date.now();
      systickNow = peek32(0xE000E018);
    }, systickMax/64000);
    
    setInterval(() => {
      let cpuPercentage = 100 - E.clip(systickDiff/systickMax*100,0,100)­;
      g.drawString("CPU used: " + cpuPercentage.toFixed(2) +"% " + systickDiff,0,0,true);
    }, 2000);
    

    Is this actually a valid way to guesstimate CPU-usage? On an bangle without boot code this shows 6-7% non-idle time while being connected to bluetooth. That drops down to 2.5% without bluetooth. Since there is a bit of stuff ongoing every 250/2000ms, that seems to be believable to me. Scrolling around in the launcher can get up to 100% as long I am actively scrolling.
    Am I correct in assuming that the systick overflows every 262ms? 16.7 million ticks at 64000 ticks every ms?

About

Avatar for halemmerich @halemmerich started