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

41
LINES

< > BotCompany Repo | #3000166 // Answer for stefanreich

New Tinybrain snippet

```synchronized static String answer(String s) {
Matches m = new Matches();
 
    if (match3("cpu usage", s))
      return formatDouble(totalPercentage, 2) + "% in Eleu process";
      
    if (match3("most active thread", s)) {
      Thread t = getMostActiveThread();
      return t == null ? "Sorry, no info." : format3("Thread name: *, cpu: *", t.getName(), formatDouble(totalPercentage, 2) + "%");
    }
    
    if (match3("cpu: get measurement interval", s))
      return interval + " ms";
      
    if (match3("cpu: are you measuring", s))
      return "Yes.";
      
    if (match3("cpu: get last measurement time", s))
      return "" + lastMeasured;
      
    if (match("cpu: list all threads", s, m)) {
      List<String> l = new ArrayList<String>();
      for (Map.Entry<Thread, Info> e : infoMap.entrySet()) {
        Thread t = e.getKey();
        Info info = e.getValue();
        l.add(formatDouble(info.percentage, 1) + "% " + format("*", t.getName()));
      }
      return slackSnippet(fromLines(l));
    }
    
    if (match("system load", s, m))
      return "System load: " + formatDouble(ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(), 1);
      
    if (match("cpu: processors", s, m)) {
      OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean();
      return "I have " + n(bean.getAvailableProcessors(), bean.getArch() +  " processor") + ".";
    }
  
return null;
}```
does not parse.

download  show line numbers   

Snippet is not live.

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #3000166
Snippet name: Answer for stefanreich
Eternal ID of this version: #3000166/1
Text MD5: c68926d670e1c14761e438ef88f24d7c
Author: someone
Category:
Type: New Tinybrain snippet
Gummipassword: eleutheria-for-user
Uploaded from IP: 69.10.46.185
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-23 19:18:10
Source code size: 1455 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 464 / 107
Referenced in: [show references]