getrusage.js
Version:
getrusage for node precompiled
55 lines • 5.16 kB
JSON
{
"name": "getrusage.js",
"version": "0.2.7",
"description": "getrusage for node precompiled",
"sideEffects": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"keywords": [
"getrusage"
],
"author": "zthxxx.me@gmail.com",
"license": "MIT",
"repository": "zthxxx/getrusage.js",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"homepage": "https://github.com/zthxxx/getrusage.js",
"bugs": {
"url": "https://github.com/zthxxx/getrusage.js/issues"
},
"files": [
"README.md",
".npmrc",
"scripts",
"getrusage",
"src",
"es",
"lib",
"dist",
"build"
],
"engines": {
"node": ">=12.0.0"
},
"devDependencies": {
"@actions/core": "^1.6.0",
"@changesets/cli": "^2.19.0",
"@npmcli/promise-spawn": "^2.0.0",
"@types/node": "^16.11.17",
"node-addon-api": "^4.2.0",
"node-gyp": "^7.1.2",
"rimraf": "^3.0.2",
"typescript": "^4.5.4"
},
"scripts": {
"clean": "pnpm clean:gyp && pnpm clean:tsbuild",
"clean:gyp": "rimraf getrusage/build",
"clean:tsbuild": "rimraf lib es tsconfig.tsbuildinfo",
"build:binary": "./scripts/build-binary.sh",
"build:entry": "pnpm clean:tsbuild && tsc",
"test": "node tests/test.js"
},
"readme": "# getrusage.js\n\n[](https://www.npmjs.com/package/getrusage.js)\n\nPOSIX system function [`getrusage()`](https://www.gnu.org/software/libc/manual/html_node/Resource-Usage.html) is usually used to examine the resource usage of a process.\n\n[`getrusage.js`](https://www.npmjs.com/package/getrusage.js) is a binding to Node.js via [Node-API](https://nodejs.org/api/n-api.html), and makes pre-build binaries for distribution, with **0 other dependencies!**\n\nYou don't need to compile (`node-gyp`) or download (`node-pre-gyp`) anything by postinstall.\n\n## Support platforms\n\n| Platform \\ Nodejs | node 12 | node 14 | node 16 | node 18 |\n| -------------------------------------------------- | ------- | ------- | ------- | ------- |\n| **Linux x64** <br>*<small>(gcc >= 4.9)</small>* | ✓ | ✓ | ✓ | ✓ | \n| **Linux arm64** <br>*<small>(gcc >= 5.1)</small>* | ✓ | ✓ | ✓ | ✓ | \n| **Linux arm32** <br>*<small>(gcc >= 5.1)</small>* | ✓ | ✓ | ✓ | ✓ | \n| **macOS x64** | ✓ | ✓ | ✓ | ✓ | \n| **macOS arm64** <br>*<small>(M1/M2 chips)</small>* | ✓ | ✓ | ✓ | ✓ | \n\n> Windows? not support yet, due to `getrusage()` is POSIX only.\n\n## Install\n\n```bash\nnpm i getrusage.js\n```\n\n## Usage\n\n```ts\nimport {\n getrusage,\n RUSAGE_SELF,\n RUSAGE_CHILDREN,\n} from 'getrusage.js'\nimport type { RUsage } from 'getrusage.js'\n\n/**\n * `getrusage()` is equivalent to `getrusage(RUSAGE_SELF)`\n * `getrusage(RUSAGE_CHILDREN)` means usage of \"All child processes (direct and indirect) that have already terminated\"\n */\nconst usage: RUsage = getrusage()\n\nconsole.log(usage)\n\n// {\n// utime: 0.513607,\n// stime: 0.011146,\n// maxrss: 65421,\n// idrss: 0,\n// ixrss: 0,\n// isrss: 0,\n// minflt: 9753,\n// majflt: 12,\n// nswap: 0,\n// inblock: 0,\n// oublock: 0,\n// msgsnd: 0,\n// msgrcv: 0,\n// nsignals: 0,\n// nvcsw: 1347,\n// nivcsw: 10\n// }\n```\n\ninterface of `RUsage` and explain fields see:\n\n```ts\n/**\n * Resource Usage data struct\n * https://www.gnu.org/software/libc/manual/html_node/Resource-Usage.html#index-struct-rusage\n */\ninterface RUsage {\n /**\n * time spent in executing user instructions (seconds)\n * sum of tv_sec and tv_usec (unit: seconds)\n */\n utime: number;\n\n /**\n * time spent in operating system code on behalf of processes (seconds)\n * sum of tv_sec and tv_usec (unit: seconds)\n */\n stime: number;\n\n /**\n * the maximum of physical memory that processes used simultaneously (kilobytes)\n * always normalized unit in kilobytes on macOS\n */\n maxrss: number;\n\n /** deprecated fields in gnu: idrss / ixrss / isrss */\n idrss: number;\n ixrss: number;\n isrss: number;\n\n /** the number of page faults which were serviced without requiring any I/O (count) */\n minflt: number;\n\n /** the number of page faults which were serviced by doing I/O (count) */\n majflt: number;\n\n nswap: number;\n inblock: number;\n oublock: number;\n\n /** number of IPC messages sent (count) */\n msgsnd: number;\n\n /** number of IPC messages received (count) */\n msgrcv: number;\n\n /** number of signals received (count) */\n nsignals: number;\n\n /**\n * the number of times processes voluntarily invoked a context switch (count) \n * (usually to wait for some service)\n */\n nvcsw: number;\n\n /**\n * the number of times an involuntary context switch took place (count)\n * because a time slice expired, or another process of higher priority was scheduled\n */\n nivcsw: number;\n}\n```\n\n## License\n\nMIT\n"
}