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

21
LINES

< > BotCompany Repo | #1013392 // Test GarbageCollectorMXBean (show total GC count & time)

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

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

1  
!7
2  
3  
p {
4  
  /*thread {
5  
  }*/
6  
  bool first = true;
7  
  repeat with sleep 1 {
8  
    List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
9  
    
10  
    long count = 0;
11  
    long timeMillis = 0;
12  
    for (GarbageCollectorMXBean gcBean : gcBeans) {
13  
      if (first) print("Collector: " +gcBean.getName());
14  
      count += gcBean.getCollectionCount();
15  
      timeMillis += gcBean.getCollectionTime();
16  
    }
17  
    first = false;
18  
    
19  
    print("GC count: " + count + ", time: " + formatDouble(toS(timeMillis), 3) + " s";
20  
  }
21  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1013392
Snippet name: Test GarbageCollectorMXBean (show total GC count & time)
Eternal ID of this version: #1013392/5
Text MD5: 6c95695a3076d8c78b5c76baba3c8003
Transpilation MD5: fcfa1616e33be929fd3ff5e5e8181261
Author: stefan
Category: javax / gc / monitoring
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-05 00:59:34
Source code size: 556 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 313 / 622
Version history: 4 change(s)
Referenced in: [show references]