!7

p {
  repeat with ms sleep 200 {
    int cores = 0;
    double totalMHz = 0, min = 1e10, max = 0;
    
    for (S line : toLines(loadTextFile("/proc/cpuinfo")))
      if (contains(line, "MHz")) {
        S s = trim(partAfterColon(line));
        ++cores;
        double mhz = parseDouble(s);
        totalMHz += mhz;
        min = min(min, mhz);
        max = max(max, mhz);
      }
      
    if (cores == 0) print("Huh?");
    else {
      double averageMHz = totalMHz/cores;
      //print("Found " + n(cores, "core") + ". Average MHz: " + iround(averageMHz));
      print("Found " + n(cores, "core") + ". MHz: " + min + (max != min ? "-" + max : ""));
    }
  }
}