Resource.hx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package eval.luv;
  2. import eval.integers.UInt64;
  3. import eval.integers.Int64;
  4. typedef RUsage = {
  5. var utime:{sec:Int64, usec:Int64};
  6. var stime:{sec:Int64, usec:Int64};
  7. var maxrss:UInt64;
  8. var ixrss:UInt64;
  9. var idrss:UInt64;
  10. var isrss:UInt64;
  11. var minflt:UInt64;
  12. var majflt:UInt64;
  13. var nswap:UInt64;
  14. var inblock:UInt64;
  15. var oublock:UInt64;
  16. var msgsnd:UInt64;
  17. var msgrcv:UInt64;
  18. var nsignals:UInt64;
  19. var nvcsw:UInt64;
  20. var nivcsw:UInt64;
  21. }
  22. /**
  23. Resource usage.
  24. @see https://aantron.github.io/luv/luv/Luv/Resource
  25. **/
  26. extern class Resource {
  27. /**
  28. Evaluates to the current uptime.
  29. **/
  30. static function uptime():Result<Float>;
  31. /**
  32. Evaluates to the load average.
  33. **/
  34. static function loadAvg():Array<Float>;
  35. /**
  36. Evaluates to the amount of free memory, in bytes.
  37. **/
  38. static function freeMemory():UInt64;
  39. /**
  40. Evaluates to the total amount of memory, in bytes.
  41. **/
  42. static function totalMemory():UInt64;
  43. /**
  44. Gets the amount of memory available to the process (in bytes) based on
  45. limits imposed by the OS.
  46. If there is no such constraint returns `null`
  47. **/
  48. static function constrainedMemory():Null<UInt64>;
  49. /**
  50. Evaluates to the priority of the process with the given pid.
  51. **/
  52. static function getPriority(pid:Int):Result<Int>;
  53. /**
  54. Sets the priority of the process with the given pid.
  55. **/
  56. static function setPriority(pid:Int, priority:Int):Result<Result.NoData>;
  57. /**
  58. Evaluates to the resident set size for the current process.
  59. **/
  60. static function residentSetMemory():Result<UInt64>;
  61. /**
  62. Gets the resource usage measures for the current process.
  63. **/
  64. static function getRUsage():Result<RUsage>;
  65. }