cancel usage of multi-thread to improve performance
This commit is contained in:
parent
23ca078e73
commit
56d88b9c45
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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[] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user