cancel usage of multi-thread to improve performance

This commit is contained in:
锦恢 2023-07-06 15:14:11 +08:00
parent 23ca078e73
commit 56d88b9c45
2 changed files with 19 additions and 8 deletions

View File

@ -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);
}

View File

@ -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<AbsPath>) {
const pools: Promise<void>[] = [];
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[] {