diff options
author | James M Snell <jasnell@gmail.com> | 2017-12-20 07:50:47 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-12-21 07:56:18 -0800 |
commit | a4f44acd6962e470006c75774f4f0b22325a9bbb (patch) | |
tree | 2122e0e5fa946d3e1a486b671ea2231d3207d0f6 /doc | |
parent | 7a0f774bb5086dddcc36f2c3987ee602d7c9bf74 (diff) | |
download | android-node-v8-a4f44acd6962e470006c75774f4f0b22325a9bbb.tar.gz android-node-v8-a4f44acd6962e470006c75774f4f0b22325a9bbb.tar.bz2 android-node-v8-a4f44acd6962e470006c75774f4f0b22325a9bbb.zip |
doc: warn about using util.inspect/util.format
Because of the potential performance bottlenecks that may be introduced
by `util.inspect()` and `util.format()` in production hot path code.
Based on real user feedback, it is not obvious that these are intended
to be debugging tools.
PR-URL: https://github.com/nodejs/node/pull/17791
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/util.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/api/util.md b/doc/api/util.md index 8f9e6ef020..a2d3c71bb6 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -250,6 +250,11 @@ without any formatting. util.format('%% %s'); // '%% %s' ``` +Please note that `util.format()` is a synchronous method that is mainly +intended as a debugging tool. Some input values can have a significant +performance overhead that can block the event loop. Use this function +with care and never in a hot code path. + ## util.inherits(constructor, superConstructor) <!-- YAML added: v0.3.0 @@ -462,6 +467,11 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 })); // chunks. ``` +Please note that `util.inspect()` is a synchronous method that is mainly +intended as a debugging tool. Some input values can have a significant +performance overhead that can block the event loop. Use this function +with care and never in a hot code path. + ### Customizing `util.inspect` colors <!-- type=misc --> |