Nodejs There are some built-in method can query the operating system information:
Such as:
process.arch acquired system is the 32-bit or 64-bit,
process.platform type of system can be obtained.
Routine:
console.log(process.arch);
console.log(process.platform);
Output:
process.memoryUsage () can get the current process memory usage, it has three methods:
rss: permanent memory size;
heapTotal: available memory dynamically allocated;
heapUsed: Used heap size.
Routine:
console.log(process.memoryUsage().rss);
console.log(process.memoryUsage().heapTotal);
console.log(process.memoryUsage().heapUsed);
Output:
NOTE: output digital bytes. In addition to 1024 have obtained is KB, in addition to 1024 and then acquired a MB, it is another addition to the 1024 acquisition of GB.
Use the command line parameters can be obtained process.argv
Routine:
// overall output parameters
the console.log (process.argv);
// parameters are input
IF (process.argv.length> 0) {
// iterate parameters
process.argv.forEach (function (Arg, index) {
Console. log (Arg, index);
});
}
Results of the:
Can be seen from the results, there are two implicit parameters: node.exe itself, the script. Plus parameters arg1, arg2, in fact, a total of four parameters.
References: