File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,8 +30,13 @@ const measureTotalTimeAsSubtest = false; // Once we move to preloading all resou
3030const defaultIterationCount = 120 ;
3131const defaultWorstCaseCount = 4 ;
3232
33- if ( ! JetStreamParams . prefetchResources && isInBrowser )
33+ if ( ! JetStreamParams . prefetchResources && isInBrowser ) {
3434 console . warn ( "Disabling resource prefetching! All compressed files must have been decompressed using `npm run decompress`" ) ;
35+ }
36+
37+ if ( JetStreamParams . forceGC && typeof globalThis . gc === "undefined" ) {
38+ console . warn ( "Force-gc is set, but globalThis.gc() is not available." ) ;
39+ }
3540
3641if ( ! isInBrowser && JetStreamParams . prefetchResources ) {
3742 // Use the wasm compiled zlib as a polyfill when decompression stream is
@@ -913,6 +918,14 @@ class Benchmark {
913918 if ( this . isDone )
914919 throw new Error ( `Cannot run Benchmark ${ this . name } twice` ) ;
915920 this . _state = BenchmarkState . PREPARE ;
921+
922+ if ( JetStreamParams . forceGC ) {
923+ // This will trigger for individual benchmarks in
924+ // GroupedBenchmarks since they delegate .run() to their inner
925+ // non-grouped benchmarks.
926+ globalThis ?. gc ( ) ;
927+ }
928+
916929 const scripts = isInBrowser ? new BrowserScripts ( this . preloads ) : new ShellScripts ( this . preloads ) ;
917930
918931 if ( ! ! this . plan . deterministicRandom )
Original file line number Diff line number Diff line change @@ -81,6 +81,10 @@ const CLI_PARAMS = {
8181 help : "Custom code to run after each iteration." ,
8282 param : "customPostIterationCode" ,
8383 } ,
84+ "force-gc" : {
85+ help : "Force garbage collection before each benchmark, requires engine support." ,
86+ param : "forceGC" ,
87+ } ,
8488} ;
8589
8690const cliParams = new Map ( ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class Params {
4343 groupDetails = false
4444
4545 RAMification = false ;
46+ forceGC = false ;
4647 dumpJSONResults = false ;
4748 dumpTestList = false ;
4849 // Override iteration and worst-case counts per workload.
@@ -70,6 +71,7 @@ class Params {
7071 this . dumpJSONResults = this . _parseBooleanParam ( sourceParams , "dumpJSONResults" ) ;
7172 this . groupDetails = this . _parseBooleanParam ( sourceParams , "groupDetails" ) ;
7273 this . dumpTestList = this . _parseBooleanParam ( sourceParams , "dumpTestList" ) ;
74+ this . forceGC = this . _parseBooleanParam ( sourceParams , "forceGC" ) ;
7375
7476 this . customPreIterationCode = this . _parseStringParam ( sourceParams , "customPreIterationCode" ) ;
7577 this . customPostIterationCode = this . _parseStringParam ( sourceParams , "customPostIterationCode" ) ;
You can’t perform that action at this time.
0 commit comments