diff --git a/resources/hdlParser/index.js b/resources/hdlParser/index.js index cf211d5..2de23de 100644 --- a/resources/hdlParser/index.js +++ b/resources/hdlParser/index.js @@ -18,14 +18,30 @@ const _hdlParser = { } }; +const debug = { + acquire: 0, + io: 0, + compute: 0 +}; async function callParser(path, func) { + const s1 = Date.now(); const wasmModule = await _hdlParser.acquire(); + debug.acquire += Date.now() - s1; + const file = _hdlParser.tempPath; const fileLength = file.length; + + const s2 = Date.now(); const source = fs.readFileSync(path, 'utf-8') + '\n'; wasmModule.FS.writeFile(_hdlParser.tempPath, source, { encoding: 'utf8' }); + debug.io += Date.now() - s2; + + const s3 = Date.now(); const res = wasmModule.ccall('call_parser', 'string', ['string', 'int', 'int'], [file, fileLength, func]); + debug.compute += Date.now() - s3; + + console.log(debug); return JSON.parse(res); } diff --git a/src/hdlParser/core.ts b/src/hdlParser/core.ts index 9d9014d..33aa625 100644 --- a/src/hdlParser/core.ts +++ b/src/hdlParser/core.ts @@ -224,7 +224,7 @@ class HdlParam { private async doHdlFast(path: AbsPath) { try { - const fast = await HdlSymbol.fast(path); + const fast = await HdlSymbol.fast(path); if (fast) { const languageId = this.alignLanguageId(fast.languageId); new HdlFile(path, @@ -239,13 +239,8 @@ class HdlParam { } public async initHdlFiles(hdlFiles: AbsPath[] | Generator) { - const pools: Promise[] = []; for (const path of hdlFiles) { - const p = this.doHdlFast(path); - pools.push(p); - } - for (const p of pools) { - await p; + await this.doHdlFast(path); } } @@ -254,7 +249,7 @@ class HdlParam { for (const hdlFile of this.getAllHdlFiles()) { hdlFile.makeInstance(); - } + } } public getTopModulesByType(type: string): HdlModule[] {