99
1010import { timerange } from '@kbn/apm-synthtrace-client' ;
1111import { castArray , once } from 'lodash' ;
12+ import { memoryUsage } from 'process' ;
1213import { bootstrap } from './bootstrap' ;
1314import { getScenario } from './get_scenario' ;
1415import { RunOptions } from './parse_run_cli_flags' ;
@@ -34,10 +35,28 @@ export async function startLiveDataUpload({
3435 teardown : scenarioTearDown ,
3536 } = await scenario ( { ...runOptions , logger, from, to } ) ;
3637
38+ function startPeriodicPerfLogging ( ) {
39+ let cpuUsage = process . cpuUsage ( ) ;
40+
41+ return setInterval ( ( ) => {
42+ cpuUsage = process . cpuUsage ( cpuUsage ) ;
43+ const mem = memoryUsage ( ) ;
44+ logger . debug (
45+ `cpu time: (user: ${ Math . round ( cpuUsage . user / 1000 ) } mss, sys: ${ Math . round (
46+ cpuUsage . system / 1000
47+ ) } ms), memory: ${ mb ( mem . heapUsed ) } /${ mb ( mem . heapTotal ) } `
48+ ) ;
49+ } , 5000 ) ;
50+ }
51+
52+ const intervalId = startPeriodicPerfLogging ( ) ;
53+
3754 const teardown = once ( async ( ) => {
3855 if ( scenarioTearDown ) {
3956 await scenarioTearDown ( clients ) ;
4057 }
58+
59+ clearInterval ( intervalId ) ;
4160 } ) ;
4261
4362 const streamManager = new StreamManager ( logger , teardown ) ;
@@ -49,6 +68,10 @@ export async function startLiveDataUpload({
4968 const bucketSizeInMs = runOptions . liveBucketSize ;
5069 let requestedUntil = from ;
5170
71+ function mb ( value : number ) : string {
72+ return Math . round ( value / 1024 ** 2 ) . toString ( ) + 'mb' ;
73+ }
74+
5275 async function uploadNextBatch ( ) {
5376 const now = Date . now ( ) ;
5477
0 commit comments