@@ -22,6 +22,7 @@ import {
22
22
convertToCSVFormat ,
23
23
convertToCloudMonitoringFormat ,
24
24
TestResult ,
25
+ log ,
25
26
} from './performanceUtils' ;
26
27
import { existsSync } from 'fs' ;
27
28
import { writeFile } from 'fs/promises' ;
@@ -72,6 +73,10 @@ const argv = yargs(process.argv.slice(2))
72
73
filename : {
73
74
type : 'string' ,
74
75
} ,
76
+ debug : {
77
+ type : 'boolean' ,
78
+ default : false ,
79
+ } ,
75
80
} )
76
81
. parseSync ( ) ;
77
82
@@ -86,8 +91,9 @@ let iterationsRemaining = argv.iterations;
86
91
function main ( ) {
87
92
let numThreads = argv . numthreads ;
88
93
if ( numThreads > iterationsRemaining ) {
89
- console . log (
90
- `${ numThreads } is greater than number of iterations (${ iterationsRemaining } ). Using ${ iterationsRemaining } threads instead.`
94
+ log (
95
+ `${ numThreads } is greater than number of iterations (${ iterationsRemaining } ). Using ${ iterationsRemaining } threads instead.` ,
96
+ argv . debug
91
97
) ;
92
98
numThreads = iterationsRemaining ;
93
99
}
@@ -105,8 +111,9 @@ function main() {
105
111
*/
106
112
function createWorker ( ) {
107
113
iterationsRemaining -- ;
108
- console . log (
109
- `Starting new iteration. Current iterations remaining: ${ iterationsRemaining } `
114
+ log (
115
+ `Starting new iteration. Current iterations remaining: ${ iterationsRemaining } ` ,
116
+ argv . debug
110
117
) ;
111
118
let testPath = '' ;
112
119
if ( argv . testtype === TRANSFER_MANAGER_TEST_TYPES . WRITE_ONE_READ_THREE ) {
@@ -136,15 +143,14 @@ function createWorker() {
136
143
} ) ;
137
144
138
145
w . on ( 'message' , data => {
139
- console . log ( 'Successfully completed iteration.' ) ;
146
+ log ( 'Successfully completed iteration.' , argv . debug ) ;
140
147
recordResult ( data ) ;
141
148
if ( iterationsRemaining > 0 ) {
142
149
createWorker ( ) ;
143
150
}
144
151
} ) ;
145
152
w . on ( 'error' , e => {
146
- console . log ( 'An error occurred.' ) ;
147
- console . log ( e ) ;
153
+ log ( e , true , true ) ;
148
154
} ) ;
149
155
}
150
156
@@ -172,15 +178,15 @@ async function recordResult(results: TestResult[] | TestResult) {
172
178
argv . filename ,
173
179
`${ convertToCSVFormat ( resultsToAppend ) } \n`
174
180
)
175
- : console . log ( convertToCSVFormat ( resultsToAppend ) ) ;
181
+ : log ( convertToCSVFormat ( resultsToAppend ) , true ) ;
176
182
} else if ( argv . format === OUTPUT_FORMATS . CLOUD_MONITORING ) {
177
183
for await ( const outputString of convertToCloudMonitoringFormat (
178
184
resultsToAppend ,
179
185
argv . bucket
180
186
) ) {
181
187
argv . filename
182
188
? await appendFile ( argv . filename , `${ outputString } \n` )
183
- : console . log ( outputString ) ;
189
+ : log ( outputString , true ) ;
184
190
}
185
191
}
186
192
}
0 commit comments