1 | ```synchronized static String answer(String s) { |
2 | Matches m = new Matches(); |
3 | |
4 | if (match3("cpu usage", s)) |
5 | return formatDouble(totalPercentage, 2) + "% in Eleu process"; |
6 | |
7 | if (match3("most active thread", s)) { |
8 | Thread t = getMostActiveThread(); |
9 | return t == null ? "Sorry, no info." : format3("Thread name: *, cpu: *", t.getName(), formatDouble(totalPercentage, 2) + "%"); |
10 | } |
11 | |
12 | if (match3("cpu: get measurement interval", s)) |
13 | return interval + " ms"; |
14 | |
15 | if (match3("cpu: are you measuring", s)) |
16 | return "Yes."; |
17 | |
18 | if (match3("cpu: get last measurement time", s)) |
19 | return "" + lastMeasured; |
20 | |
21 | if (match("cpu: list all threads", s, m)) { |
22 | List<String> l = new ArrayList<String>(); |
23 | for (Map.Entry<Thread, Info> e : infoMap.entrySet()) { |
24 | Thread t = e.getKey(); |
25 | Info info = e.getValue(); |
26 | l.add(formatDouble(info.percentage, 1) + "% " + format("*", t.getName())); |
27 | } |
28 | return slackSnippet(fromLines(l)); |
29 | } |
30 | |
31 | if (match("system load", s, m)) |
32 | return "System load: " + formatDouble(ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(), 1); |
33 | |
34 | if (match("cpu: processors", s, m)) { |
35 | OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean(); |
36 | return "I have " + n(bean.getAvailableProcessors(), bean.getArch() + " processor") + "."; |
37 | } |
38 | |
39 | return null; |
40 | }``` |
41 | does not parse. |
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: | #3000164 |
Snippet name: | Answer for stefanreich |
Eternal ID of this version: | #3000164/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:12:38 |
Source code size: | 1455 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 493 / 116 |
Referenced in: | [show references] |