@@ -9,7 +9,6 @@ import { Scenario, TestCase } from './scenarios.js';
99import { consoleGroup } from './util/console.js' ;
1010import { WebVitals , WebVitalsCollector } from './vitals/index.js' ;
1111
12- const cpuThrottling = 4 ;
1312const networkConditions = 'Fast 3G' ;
1413
1514// Same as puppeteer-core PredefinedNetworkConditions
@@ -42,6 +41,7 @@ export class Metrics {
4241
4342export interface MetricsCollectorOptions {
4443 headless : boolean ;
44+ cpuThrottling : number ;
4545}
4646
4747export class MetricsCollector {
@@ -50,6 +50,7 @@ export class MetricsCollector {
5050 constructor ( options ?: Partial < MetricsCollectorOptions > ) {
5151 this . _options = {
5252 headless : false ,
53+ cpuThrottling : 4 ,
5354 ...options
5455 } ;
5556 }
@@ -59,7 +60,7 @@ export class MetricsCollector {
5960 return consoleGroup ( async ( ) => {
6061 const aResults = await this . _collect ( testCase , 'A' , testCase . a ) ;
6162 const bResults = await this . _collect ( testCase , 'B' , testCase . b ) ;
62- return new Result ( testCase . name , cpuThrottling , networkConditions , aResults , bResults ) ;
63+ return new Result ( testCase . name , this . _options . cpuThrottling , networkConditions , aResults , bResults ) ;
6364 } ) ;
6465 }
6566
@@ -119,7 +120,7 @@ export class MetricsCollector {
119120 uploadThroughput : PredefinedNetworkConditions [ networkConditions ] . upload ,
120121 downloadThroughput : PredefinedNetworkConditions [ networkConditions ] . download ,
121122 } ) ;
122- await cdp . send ( 'Emulation.setCPUThrottlingRate' , { rate : cpuThrottling } ) ;
123+ await cdp . send ( 'Emulation.setCPUThrottlingRate' , { rate : this . _options . cpuThrottling } ) ;
123124
124125 // Collect CPU and memory info 10 times per second.
125126 const perfSampler = await PerfMetricsSampler . create ( cdp , 100 ) ;
0 commit comments