I've made a Node.js
app that makes exactly the same thing that another solution in C#
. The both app get all the javascript files from a directory recursively and execute uglify-js
command to minify the files.
My project has about 150 JavaScript files to minify and the C#
approach takes about 22s to do all the stuff (using threads).
After reading Node.js documentation and books, I've decided to do the Node.js
way. I've already did that but I can't do reporting total time Node.js
do the stuff because its asynchronous approach...
(yeah, I know, I use threads in C#
that was asynchronous too)
So, what's the better way to get the Node.js app total time execution?
I'm using Node.js v0.10.13
as as win32
environment.
Node. js uses non-blocking, event driven I/O to offer efficiency and remain lightweight in terms of in-memory usage to data intensive real time web applications that run in various distributed environments or devices.
The standard library comes with asynchronous commands and helps with non-blocking paradigms. Node JS is an excellent choice for developers in real-time applications and has proven to be successful in similar use-cases across the industry.
At the very start of your script, use console.time('Some_Name_Here');
, and then use console.timeEnd('Some_Name_Here');
wherever the script finishes its execution.
It's a quick, native functionality of Node.js, and prevents you from having to initialize a new Date object.
Here's some short documentation on the console.time()
method: http://nodejs.org/api/stdio.html#stdio_console_time_label.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With