@@ -13,9 +13,6 @@ const DEFAULT_STATE_DIR = path.join(
1313) ;
1414
1515let STATE_DIR = DEFAULT_STATE_DIR ;
16- const PROFILE_READ_CANDIDATE_MULTIPLIER = 3 ;
17- const PROFILE_READ_MIN_CANDIDATES = 20 ;
18- const PROFILE_READ_MAX_CANDIDATES = 60 ;
1916const PROFILE_READ_ENRICH_CONCURRENCY = 5 ;
2017const PROFILE_READ_ENRICH_TIMEOUT_MS = 1000 ;
2118
@@ -98,17 +95,6 @@ async function enrichProfileMetadataOnDemand(
9895 } ) ) ;
9996}
10097
101- function getCandidateLimit ( limit ?: number ) : number {
102- if ( limit === undefined ) return PROFILE_READ_MAX_CANDIDATES ;
103- return Math . max (
104- limit ,
105- Math . min (
106- PROFILE_READ_MAX_CANDIDATES ,
107- Math . max ( PROFILE_READ_MIN_CANDIDATES , limit * PROFILE_READ_CANDIDATE_MULTIPLIER ) ,
108- ) ,
109- ) ;
110- }
111-
11298class Daemon {
11399 private ipcServer : net . Server | null = null ;
114100 private bridge : DevToolsBridge ;
@@ -352,18 +338,20 @@ class Daemon {
352338 }
353339
354340 case 'profile-slow' : {
355- const candidateLimit = getCandidateLimit ( cmd . limit ) ;
341+ const requestedLimit = cmd . limit ;
342+ const candidateLimit = Math . max ( requestedLimit ?? 10 , cmd . candidateLimit ?? requestedLimit ?? 10 ) ;
356343 const candidates = this . profiler . getSlowest ( this . tree , candidateLimit ) ;
357344 await enrichProfileMetadataOnDemand ( candidates , this . tree , this . bridge , this . profiler ) ;
358- const slowest = this . profiler . getSlowest ( this . tree , candidateLimit ) ;
345+ const slowest = this . profiler . getSlowest ( this . tree , requestedLimit ?? candidateLimit ) ;
359346 return { ok : true , data : slowest } ;
360347 }
361348
362349 case 'profile-rerenders' : {
363- const candidateLimit = getCandidateLimit ( cmd . limit ) ;
350+ const requestedLimit = cmd . limit ;
351+ const candidateLimit = Math . max ( requestedLimit ?? 10 , cmd . candidateLimit ?? requestedLimit ?? 10 ) ;
364352 const candidates = this . profiler . getMostRerenders ( this . tree , candidateLimit ) ;
365353 await enrichProfileMetadataOnDemand ( candidates , this . tree , this . bridge , this . profiler ) ;
366- const rerenders = this . profiler . getMostRerenders ( this . tree , candidateLimit ) ;
354+ const rerenders = this . profiler . getMostRerenders ( this . tree , requestedLimit ?? candidateLimit ) ;
367355 return { ok : true , data : rerenders } ;
368356 }
369357
0 commit comments