Resource.hx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. Returns `null` when unknown.
  38. **/
  39. static function freeMemory():Null<UInt64>;
  40. /**
  41. Evaluates to the total amount of memory, in bytes.
  42. Returns `null` when unknown.
  43. **/
  44. static function totalMemory():Null<UInt64>;
  45. /**
  46. Gets the amount of memory available to the process (in bytes) based on
  47. limits imposed by the OS.
  48. If there is no such constraint returns `null`
  49. **/
  50. static function constrainedMemory():Null<UInt64>;
  51. /**
  52. Evaluates to the priority of the process with the given pid.
  53. **/
  54. static function getPriority(pid:Int):Result<Int>;
  55. /**
  56. Sets the priority of the process with the given pid.
  57. **/
  58. static function setPriority(pid:Int, priority:Int):Result<Result.NoData>;
  59. /**
  60. Evaluates to the resident set size for the current process.
  61. **/
  62. static function residentSetMemory():Result<UInt64>;
  63. /**
  64. Gets the resource usage measures for the current process.
  65. **/
  66. static function getRUsage():Result<RUsage>;
  67. }