| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e2b8393 commit 870108a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,7 +93,7 @@ Example: | |||
| 93 | 93 | ; | |
| 94 | 94 | } | |
| 95 | 95 | console.timeEnd('100-elements'); | |
| 96 | - // prints 100-elements: 262ms | ||
| 96 | + // prints 100-elements: 225.438ms | ||
| 97 | 97 | ||
| 98 | 98 | ### console.trace(message[, ...]) | |
| 99 | 99 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,7 +56,7 @@ Console.prototype.dir = function(object, options) { | |||
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | 58 | Console.prototype.time = function(label) { | |
| 59 | - this._times.set(label, Date.now()); | ||
| 59 | + this._times.set(label, process.hrtime()); | ||
| 60 | 60 | }; | |
| 61 | 61 | ||
| 62 | 62 | ||
@@ -65,8 +65,9 @@ Console.prototype.timeEnd = function(label) { | |||
| 65 | 65 | if (!time) { | |
| 66 | 66 | throw new Error('No such label: ' + label); | |
| 67 | 67 | } | |
| 68 | - var duration = Date.now() - time; | ||
| 69 | - this.log('%s: %dms', label, duration); | ||
| 68 | + const duration = process.hrtime(time); | ||
| 69 | + const ms = duration[0] * 1000 + duration[1] / 1e6; | ||
| 70 | + this.log('%s: %sms', label, ms.toFixed(3)); | ||
| 70 | 71 | }; | |
| 71 | 72 | ||
| 72 | 73 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,8 +68,8 @@ assert.notEqual(-1, strings.shift().indexOf('foo: [Object]')); | |||
| 68 | 68 | assert.equal(-1, strings.shift().indexOf('baz')); | |
| 69 | 69 | assert.equal('Trace: This is a {"formatted":"trace"} 10 foo', | |
| 70 | 70 | strings.shift().split('\n').shift()); | |
| 71 | - assert.ok(/^label: \d+ms$/.test(strings.shift().trim())); | ||
| 72 | - assert.ok(/^__proto__: \d+ms$/.test(strings.shift().trim())); | ||
| 73 | - assert.ok(/^constructor: \d+ms$/.test(strings.shift().trim())); | ||
| 74 | - assert.ok(/^hasOwnProperty: \d+ms$/.test(strings.shift().trim())); | ||
| 71 | + assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
| 72 | + assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
| 73 | + assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
| 74 | + assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
| 75 | 75 | assert.equal(strings.length, 0); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments