diff options
author | James M Snell <jasnell@gmail.com> | 2018-01-10 09:42:10 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-01-31 15:24:58 -0800 |
commit | 6bcd31f2f4a518f70646a72e7a6e42aa6ca90469 (patch) | |
tree | 39e2cb0645a6fd8b907a87a37c555fd86bdda26b /test | |
parent | 6e312c5cc7300e8c5d23301c970a1ac978950ff5 (diff) | |
download | android-node-v8-6bcd31f2f4a518f70646a72e7a6e42aa6ca90469.tar.gz android-node-v8-6bcd31f2f4a518f70646a72e7a6e42aa6ca90469.tar.bz2 android-node-v8-6bcd31f2f4a518f70646a72e7a6e42aa6ca90469.zip |
perf_hooks: add warning when too many entries in the timeline
PR-URL: https://github.com/nodejs/node/pull/18087
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-performance-warning.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/parallel/test-performance-warning.js b/test/parallel/test-performance-warning.js new file mode 100644 index 0000000000..f3104677a7 --- /dev/null +++ b/test/parallel/test-performance-warning.js @@ -0,0 +1,29 @@ +// Flags: --no-warnings +'use strict'; + +const common = require('../common'); +const { performance } = require('perf_hooks'); +const assert = require('assert'); + +assert.strictEqual(performance.length, 1); +assert.strictEqual(performance.maxEntries, 150); + +performance.maxEntries = 1; + +[-1, 0xffffffff + 1, '', null, undefined, Infinity].forEach((i) => { + common.expectsError( + () => performance.maxEntries = i, + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + } + ); +}); + +common.expectWarning('Warning', [ + 'Possible perf_hooks memory leak detected. There are 2 entries in the ' + + 'Performance Timeline. Use the clear methods to remove entries that are no ' + + 'longer needed or set performance.maxEntries equal to a higher value ' + + '(currently the maxEntries is 1).']); + +performance.mark('test'); |