Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1010369 // Display current MHz [Linux]

JavaX source code (desktop) [tags: archive use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (934L/7K).

!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 : ""));
    }
  }
}

Author comment

Began life as a copy of #1010368

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): cfunsshuasjs, gwrvuhgaqvyk, jtubtzbbkimh, mqqgnosmbjvj, onxytkatvevr, tvejysmllsmz

No comments. add comment

Snippet ID: #1010369
Snippet name: Display current MHz [Linux]
Eternal ID of this version: #1010369/8
Text MD5: d93f13ebf1f0e0fc48a95d32c0e252e7
Transpilation MD5: 8656e24405981e6e16fa99c3be812bec
Author: stefan
Category: javax / os
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): Yes
Created/modified: 2017-09-13 02:12:58
Source code size: 694 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 554 / 1270
Version history: 7 change(s)
Referenced in: #1010371 - Display current CPU speed (MHz) as big text [Linux]