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).

1  
!7
2  
3  
p {
4  
  repeat with ms sleep 200 {
5  
    int cores = 0;
6  
    double totalMHz = 0, min = 1e10, max = 0;
7  
    
8  
    for (S line : toLines(loadTextFile("/proc/cpuinfo")))
9  
      if (contains(line, "MHz")) {
10  
        S s = trim(partAfterColon(line));
11  
        ++cores;
12  
        double mhz = parseDouble(s);
13  
        totalMHz += mhz;
14  
        min = min(min, mhz);
15  
        max = max(max, mhz);
16  
      }
17  
      
18  
    if (cores == 0) print("Huh?");
19  
    else {
20  
      double averageMHz = totalMHz/cores;
21  
      //print("Found " + n(cores, "core") + ". Average MHz: " + iround(averageMHz));
22  
      print("Found " + n(cores, "core") + ". MHz: " + min + (max != min ? "-" + max : ""));
23  
    }
24  
  }
25  
}

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: 555 / 1274
Version history: 7 change(s)
Referenced in: [show references]