Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
console: use a plain object for the the error stack
Using a object instead of an Error is sufficient as the Error
itself won't be used but only the stack trace that would
otherwise be created twice.

This improves the overall .trace() performance.
  • Loading branch information
BridgeAR committed Jun 19, 2017
commit f0baeea135d03f073058bc4af519552f205dbc5f
9 changes: 4 additions & 5 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ Console.prototype.timeEnd = function timeEnd(label) {


Console.prototype.trace = function trace(...args) {
// TODO probably can to do this better with V8's debug object once that is
// exposed.
var err = new Error();
err.name = 'Trace';
err.message = util.format.apply(null, args);
const err = {
name: 'Trace',
message: util.format.apply(null, args)
};
Error.captureStackTrace(err, trace);
this.error(err.stack);
};
Expand Down