Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import com.sun.jna.Native;
  2.  
  3. public class JNA_PSAPI_Test_optimized {
  4.  
  5. public static native boolean GetPerformanceInfo(PerformanceInformationStruct pPerformanceInformation, int cb);
  6.  
  7. static {
  8. Native.register("psapi");
  9. }
  10.  
  11. public static void main(String[] args) throws InterruptedException {
  12. PerformanceInformationStruct tPerfInfo = new PerformanceInformationStruct();
  13.  
  14. while (true){
  15. GetPerformanceInfo(tPerfInfo, 104);
  16. System.out.println("nonPagedPool (MB): "+tPerfInfo.KernelNonpaged * tPerfInfo.PageSize / Math.pow(1024,2));
  17. Thread.sleep(1000);
  18. }
  19. }
  20. }
  21.  
  22. import java.util.Arrays;
  23. import java.util.List;
  24. import com.sun.jna.Structure;
  25.  
  26. public class PerformanceInformationStruct extends Structure {
  27. public int cb;
  28. public long CommitTotal;
  29. public long CommitLimit;
  30. public long CommitPeak;
  31. public long PhysicalTotal;
  32. public long PhysicalAvailable;
  33. public long SystemCache;
  34. public long KernelTotal;
  35. public long KernelPaged;
  36. public long KernelNonpaged;
  37. public long PageSize;
  38. public int HandleCount;
  39. public int ProcessCount;
  40. public int ThreadCount;
  41. public PerformanceInformationStruct() {
  42. super();
  43. }
  44.  
  45. @Override
  46. protected List<String> getFieldOrder() {
  47. return Arrays.asList(new String[]{"cb", "CommitTotal", "CommitLimit", "CommitPeak", "PhysicalTotal", "PhysicalAvailable", "SystemCache", "KernelTotal", "KernelPaged", "KernelNonpaged", "PageSize", "HandleCount", "ProcessCount", "ThreadCount"});
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement