@@ -16,6 +16,7 @@ import { nonStringFields } from './CubeValidator';
1616import { CubeDictionary } from './CubeDictionary' ;
1717import { ErrorReporter } from './ErrorReporter' ;
1818import { camelizeCube } from './utils' ;
19+ import { perfTracker } from './PerfTracker' ;
1920
2021type EscapeStateStack = {
2122 inFormattedStr ?: boolean ;
@@ -92,7 +93,9 @@ export class YamlCompiler {
9293 for ( const key of Object . keys ( yamlObj ) ) {
9394 if ( key === 'cubes' ) {
9495 ( yamlObj . cubes || [ ] ) . forEach ( ( { name, ...cube } ) => {
96+ const transpileAndPrepareJsFileTimer = perfTracker . start ( 'yaml-transpileAndPrepareJsFile' ) ;
9597 const transpiledFile = this . transpileAndPrepareJsFile ( file , 'cube' , { name, ...cube } , errorsReport ) ;
98+ transpileAndPrepareJsFileTimer . end ( ) ;
9699 this . dataSchemaCompiler ?. compileJsFile ( transpiledFile , errorsReport ) ;
97100 } ) ;
98101 } else if ( key === 'views' ) {
@@ -134,7 +137,10 @@ export class YamlCompiler {
134137
135138 cubeObj . hierarchies = this . yamlArrayToObj ( cubeObj . hierarchies || [ ] , 'hierarchies' , errorsReport ) ;
136139
137- return this . transpileYaml ( cubeObj , [ ] , cubeObj . name , errorsReport ) ;
140+ const transpileYamlTimer = perfTracker . start ( 'transpileYaml' ) ;
141+ const res = this . transpileYaml ( cubeObj , [ ] , cubeObj . name , errorsReport ) ;
142+ transpileYamlTimer . end ( ) ;
143+ return res ;
138144 }
139145
140146 private transpileYaml ( obj , propertyPath , cubeName , errorsReport : ErrorReporter ) {
@@ -163,7 +169,9 @@ export class YamlCompiler {
163169 if ( propertyPath [ propertyPath . length - 1 ] === 'values' ) {
164170 if ( typeof code === 'string' ) {
165171 if ( code . match ( PY_TEMPLATE_SYNTAX ) ) {
172+ const parsePythonAndTranspileToJsTimer184 = perfTracker . start ( 'parsePythonAndTranspileToJs call 184' ) ;
166173 ast = this . parsePythonAndTranspileToJs ( `f"${ this . escapeDoubleQuotes ( code ) } "` , errorsReport ) ;
174+ parsePythonAndTranspileToJsTimer184 . end ( ) ;
167175 } else {
168176 ast = t . stringLiteral ( code ) ;
169177 }
@@ -178,7 +186,9 @@ export class YamlCompiler {
178186 }
179187 }
180188 if ( ast === null ) {
189+ const parsePythonAndTranspileToJsTimer201 = perfTracker . start ( 'parsePythonAndTranspileToJs call 201' ) ;
181190 ast = this . parsePythonAndTranspileToJs ( code , errorsReport ) ;
191+ parsePythonAndTranspileToJsTimer201 . end ( ) ;
182192 }
183193 return this . extractProgramBodyIfNeeded ( ast ) ;
184194 } ) . filter ( ast => ! ! ast ) ) ) ] ) ;
@@ -189,7 +199,9 @@ export class YamlCompiler {
189199 }
190200
191201 if ( propertyPath [ propertyPath . length - 1 ] === 'extends' ) {
202+ const parsePythonAndTranspileToJsTimer214 = perfTracker . start ( 'parsePythonAndTranspileToJs call 214' ) ;
192203 const ast = this . parsePythonAndTranspileToJs ( obj , errorsReport ) ;
204+ parsePythonAndTranspileToJsTimer214 . end ( ) ;
193205 return this . astIntoArrowFunction ( ast , obj , cubeName , name => this . cubeDictionary . resolveCube ( name ) ) ;
194206 } else if ( typeof obj === 'string' ) {
195207 let code = obj ;
@@ -203,7 +215,9 @@ export class YamlCompiler {
203215 code = `f"${ this . escapeDoubleQuotes ( obj ) } "` ;
204216 }
205217
218+ const parsePythonAndTranspileToJsTimer225 = perfTracker . start ( 'parsePythonAndTranspileToJs call 225' ) ;
206219 const ast = this . parsePythonAndTranspileToJs ( code , errorsReport ) ;
220+ parsePythonAndTranspileToJsTimer225 . end ( ) ;
207221 return this . extractProgramBodyIfNeeded ( ast ) ;
208222 }
209223
@@ -288,7 +302,9 @@ export class YamlCompiler {
288302 }
289303
290304 private parsePythonIntoArrowFunction ( codeString : string , cubeName , originalObj , errorsReport : ErrorReporter ) {
305+ const parsePythonAndTranspileToJsTimer301 = perfTracker . start ( 'parsePythonAndTranspileToJs call 301' ) ;
291306 const ast = this . parsePythonAndTranspileToJs ( codeString , errorsReport ) ;
307+ parsePythonAndTranspileToJsTimer301 . end ( ) ;
292308 return this . astIntoArrowFunction ( ast as any , codeString , cubeName ) ;
293309 }
294310
@@ -298,8 +314,12 @@ export class YamlCompiler {
298314 }
299315
300316 try {
317+ const parsePythonAndTranspileToJsTimer = perfTracker . start ( 'PythonParser->transpileToJs()' ) ;
318+
301319 const pythonParser = new PythonParser ( codeString ) ;
302- return pythonParser . transpileToJs ( ) ;
320+ const res = pythonParser . transpileToJs ( ) ;
321+ parsePythonAndTranspileToJsTimer . end ( ) ;
322+ return res ;
303323 } catch ( e : any ) {
304324 errorsReport . error ( `Can't parse python expression. Most likely this type of syntax isn't supported yet: ${ e . message || e } ` ) ;
305325 }
@@ -308,6 +328,7 @@ export class YamlCompiler {
308328 }
309329
310330 private astIntoArrowFunction ( input : t . Program | t . NullLiteral , codeString : string , cubeName , resolveSymbol ?: ( string ) => any) {
331+ const astIntoArrowFunctionTimer = perfTracker . start ( 'astIntoArrowFunction' ) ;
311332 const initialJs = babelGenerator ( input , { } , codeString ) . code ;
312333
313334 // Re-parse generated JS to set all necessary parent paths
@@ -332,6 +353,7 @@ export class YamlCompiler {
332353 babelTraverse ( ast , traverseObj ) ;
333354
334355 const body : any = ast . program . body [ 0 ] ;
356+ astIntoArrowFunctionTimer . end ( ) ;
335357 return body ?. expression ;
336358 }
337359
0 commit comments