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

42
LINES

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

New Tinybrain snippet

1  
parses.
2  
```??? synchronized static String answer(String s) {
3  
STA Matches m = new Matches();
4  
???  
5  
???     if (match3("cpu usage", s))
6  
STA       return formatDouble(totalPercentage, 2) + "% in Eleu process";
7  
???       
8  
???     if (match3("most active thread", s)) {
9  
STA       Thread t = getMostActiveThread();
10  
STA       return t == null ? "Sorry, no info." : format3("Thread name: *, cpu: *", t.getName(), formatDouble(totalPercentage, 2) + "%");
11  
???     }
12  
???     
13  
???     if (match3("cpu: get measurement interval", s))
14  
STA       return interval + " ms";
15  
???       
16  
???     if (match3("cpu: are you measuring", s))
17  
STA       return "Yes.";
18  
???       
19  
???     if (match3("cpu: get last measurement time", s))
20  
STA       return "" + lastMeasured;
21  
???       
22  
???     if (match("cpu: list all threads", s, m)) {
23  
STA       List<String> l = new ArrayList<String>();
24  
???       for (Map.Entry<Thread, Info> e : infoMap.entrySet()) {
25  
STA         Thread t = e.getKey();
26  
STA         Info info = e.getValue();
27  
STA         l.add(formatDouble(info.percentage, 1) + "% " + format("*", t.getName()));
28  
???       }
29  
STA       return slackSnippet(fromLines(l));
30  
???     }
31  
???     
32  
???     if (match("system load", s, m))
33  
STA       return "System load: " + formatDouble(ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(), 1);
34  
???       
35  
???     if (match("cpu: processors", s, m)) {
36  
STA       OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean();
37  
STA       return "I have " + n(bean.getAvailableProcessors(), bean.getArch() +  " processor") + ".";
38  
???     }
39  
???   
40  
STA return null;
41  
??? }
42  
```

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: #3000170
Snippet name: Answer for stefanreich
Eternal ID of this version: #3000170/1
Text MD5: 14b03eec63b5c956452dd86cd97b40cb
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 20:34:32
Source code size: 1608 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 452 / 106
Referenced in: [show references]