| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ec5443c commit 90ecc9b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + let arr = new Array(300_000).fill('a'); | ||
| 2 | + | ||
| 3 | + for (let index = 0; index < arr.length; index++) { | ||
| 4 | + arr[index] = Math.random(); | ||
| 5 | + } | ||
| 6 | + | ||
| 7 | + arr = []; | ||
| 8 | + // .gc() is called to generate a Mark-sweep event | ||
| 9 | + global.gc(); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // This test verifies that `--trace-gc` flag is well integrated. | ||
| 4 | + // We'll check here, that the console outputs gc events properly. | ||
| 5 | + require('../common'); | ||
| 6 | + | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + const { spawnSync } = require('child_process'); | ||
| 9 | + | ||
| 10 | + const fixtures = require('../common/fixtures'); | ||
| 11 | + | ||
| 12 | + { | ||
| 13 | + const childProcess = spawnSync(process.execPath, [ | ||
| 14 | + '--trace-gc', | ||
| 15 | + '--expose-gc', | ||
| 16 | + fixtures.path('gc.js'), | ||
| 17 | + ]); | ||
| 18 | + const output = childProcess.stdout.toString().trim(); | ||
| 19 | + const lines = splitByLine(output); | ||
| 20 | + | ||
| 21 | + const scavengeRegex = /\bScavenge\b/; | ||
| 22 | + const expectedOutput = [ | ||
| 23 | + scavengeRegex, | ||
| 24 | + scavengeRegex, | ||
| 25 | + scavengeRegex, | ||
| 26 | + scavengeRegex, | ||
| 27 | + /\bMark-sweep\b/, | ||
| 28 | + ]; | ||
| 29 | + lines.forEach((line, index) => { | ||
| 30 | + assert.match(line, expectedOutput[index]); | ||
| 31 | + }); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * HELPERS | ||
| 36 | + */ | ||
| 37 | + | ||
| 38 | + function splitByLine(str) { | ||
| 39 | + return str.split(/\n/); | ||
| 40 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments