Node.js combat 5: the operating system command line.

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:

Node.js combat 5: the operating system command line
console.log(process.arch);
console.log(process.platform);

Output:

Node.js combat 5: the operating system command line

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:

Node.js combat 5: the operating system command line

 

console.log(process.memoryUsage().rss);
console.log(process.memoryUsage().heapTotal);
console.log(process.memoryUsage().heapUsed);

Output:

Node.js combat 5: the operating system command line

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:

Node.js combat 5: the operating system command line
// 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:

Node.js combat 5: the operating system command line

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:

Node.js combat 5: the operating system command line
 

Guess you like

Origin www.cnblogs.com/w2sft/p/12008922.html