-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow customizable time units in console.time #29099
Comments
I'm not an expert, but I think that globals such as Let me know what do you think |
We can't add new parameters to console methods, but the time format is implementation defined. We could make it more human readable based on the duration. I would be fine with something like |
cc @nodejs/console |
@devsnek That sounds wonderful to me! Thanks |
Have you tried time-span & time-stamp npm packages.. |
@nvispute It looks like |
Well its always a manual v/s a package :P no middle way to it.. and the alternative you listed is something i have been seeing since i start to code :) so i believe that would only be the way until something comes ups when it comes up |
@nvispute What I'm suggesting as a feature is to get around the manual way and the package way - to just include it with Node.js |
When timeEnd function is called, display result with a suitable time unit instead of a big amount of milliseconds. Refs: #29099 PR-URL: #29251 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
When timeEnd function is called, display result with a suitable time unit instead of a big amount of milliseconds. Refs: #29099 PR-URL: #29251 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
As it landed with v13.0.0, I think this issue can be closed. |
The Problem
I am trying to output time taken in seconds using the built in
console.time()
andconsole.timeEnd()
functions.Currently, my code and output looks like this:
Output:
Time taken: 34239.098ms
The Solution
I would like to be able to pass in an optional parameter to
console.timeEnd()
to be able to output the results in different units of time rather than milliseconds.Example:
Output:
Time taken: 34.239s
Current Alternative
This is the best alternative that I've currently found:
Output:
Time taken: 34.239s
Conclusion
Normally I do use milliseconds with my output - and it should remain the default. However I have come across numerous asynchronous processes I'd like to easily measure final time for. Reading 12168532.35ms instead of 3.38h is slightly more difficult.
Thanks for your consideration!
The text was updated successfully, but these errors were encountered: