98eb1cac3c2ecfbb1042db209d88caa74ee6ca9d.svn-base 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package cn.com.goldenwater.target;
  2. import cn.com.goldenwater.dcproj.utils.Arith;
  3. /**
  4. * 內存相关信息
  5. *
  6. * @author ruoyi
  7. */
  8. public class Mem {
  9. /**
  10. * 内存总量
  11. */
  12. private double total;
  13. /**
  14. * 已用内存
  15. */
  16. private double used;
  17. /**
  18. * 剩余内存
  19. */
  20. private double free;
  21. public double getTotal() {
  22. return Arith.div(total, (1024 * 1024 * 1024), 2);
  23. }
  24. public void setTotal(long total) {
  25. this.total = total;
  26. }
  27. public double getUsed() {
  28. return Arith.div(used, (1024 * 1024 * 1024), 2);
  29. }
  30. public void setUsed(long used) {
  31. this.used = used;
  32. }
  33. public double getFree() {
  34. return Arith.div(free, (1024 * 1024 * 1024), 2);
  35. }
  36. public void setFree(long free) {
  37. this.free = free;
  38. }
  39. public double getUsage() {
  40. return Arith.mul(Arith.div(used, total, 4), 100);
  41. }
  42. @Override
  43. public String toString() {
  44. return "Mem{" +
  45. "total=" + total +
  46. ", used=" + used +
  47. ", free=" + free +
  48. '}';
  49. }
  50. }