| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 89bf654 commit fa2eaa5
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,11 @@ const bench = common.createBenchmark(main, { | |||
| 21 | 21 | ||
| 22 | 22 | 'ReadableStream.tee', | |
| 23 | 23 | ], | |
| 24 | + }, { | ||
| 25 | + // Each case collects garbage right before bench.start() so that the | ||
| 26 | + // timed window measures the work under test rather than leftover | ||
| 27 | + // GC work from the setup phase. | ||
| 28 | + flags: ['--expose-gc'], | ||
| 24 | 29 | }); | |
| 25 | 30 | ||
| 26 | 31 | let readableStream; | |
@@ -33,6 +38,7 @@ let teeResult; | |||
| 33 | 38 | function main({ n, kind }) { | |
| 34 | 39 | switch (kind) { | |
| 35 | 40 | case 'ReadableStream': | |
| 41 | + globalThis.gc(); | ||
| 36 | 42 | bench.start(); | |
| 37 | 43 | for (let i = 0; i < n; ++i) | |
| 38 | 44 | readableStream = new ReadableStream(); | |
@@ -42,6 +48,7 @@ function main({ n, kind }) { | |||
| 42 | 48 | assert.ok(readableStream); | |
| 43 | 49 | break; | |
| 44 | 50 | case 'WritableStream': | |
| 51 | + globalThis.gc(); | ||
| 45 | 52 | bench.start(); | |
| 46 | 53 | for (let i = 0; i < n; ++i) | |
| 47 | 54 | writableStream = new WritableStream(); | |
@@ -51,6 +58,7 @@ function main({ n, kind }) { | |||
| 51 | 58 | assert.ok(writableStream); | |
| 52 | 59 | break; | |
| 53 | 60 | case 'TransformStream': | |
| 61 | + globalThis.gc(); | ||
| 54 | 62 | bench.start(); | |
| 55 | 63 | for (let i = 0; i < n; ++i) | |
| 56 | 64 | transformStream = new TransformStream(); | |
@@ -62,6 +70,7 @@ function main({ n, kind }) { | |||
| 62 | 70 | case 'ReadableStreamDefaultReader': { | |
| 63 | 71 | const readers = Array.from({ length: n }, () => new ReadableStream()); | |
| 64 | 72 | ||
| 73 | + globalThis.gc(); | ||
| 65 | 74 | bench.start(); | |
| 66 | 75 | for (let i = 0; i < n; ++i) | |
| 67 | 76 | readableStreamDefaultReader = new ReadableStreamDefaultReader(readers[i]); | |
@@ -74,6 +83,7 @@ function main({ n, kind }) { | |||
| 74 | 83 | case 'ReadableStreamBYOBReader': { | |
| 75 | 84 | const readers = Array.from({ length: n }, () => new ReadableStream({ type: 'bytes' })); | |
| 76 | 85 | ||
| 86 | + globalThis.gc(); | ||
| 77 | 87 | bench.start(); | |
| 78 | 88 | for (let i = 0; i < n; ++i) | |
| 79 | 89 | readableStreamBYOBReader = new ReadableStreamBYOBReader(readers[i]); | |
@@ -86,6 +96,7 @@ function main({ n, kind }) { | |||
| 86 | 96 | case 'ReadableStream.tee': { | |
| 87 | 97 | const streams = Array.from({ length: n }, () => new ReadableStream()); | |
| 88 | 98 | ||
| 99 | + globalThis.gc(); | ||
| 89 | 100 | bench.start(); | |
| 90 | 101 | for (let i = 0; i < n; ++i) | |
| 91 | 102 | teeResult = streams[i].tee(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments