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) {
|
async function callParser(path, func) {
|
||||||
|
const s1 = Date.now();
|
||||||
const wasmModule = await _hdlParser.acquire();
|
const wasmModule = await _hdlParser.acquire();
|
||||||
|
debug.acquire += Date.now() - s1;
|
||||||
|
|
||||||
const file = _hdlParser.tempPath;
|
const file = _hdlParser.tempPath;
|
||||||
const fileLength = file.length;
|
const fileLength = file.length;
|
||||||
|
|
||||||
|
const s2 = Date.now();
|
||||||
const source = fs.readFileSync(path, 'utf-8') + '\n';
|
const source = fs.readFileSync(path, 'utf-8') + '\n';
|
||||||
wasmModule.FS.writeFile(_hdlParser.tempPath, source, { encoding: 'utf8' });
|
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]);
|
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);
|
return JSON.parse(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class HdlParam {
|
|||||||
|
|
||||||
private async doHdlFast(path: AbsPath) {
|
private async doHdlFast(path: AbsPath) {
|
||||||
try {
|
try {
|
||||||
const fast = await HdlSymbol.fast(path);
|
const fast = await HdlSymbol.fast(path);
|
||||||
if (fast) {
|
if (fast) {
|
||||||
const languageId = this.alignLanguageId(fast.languageId);
|
const languageId = this.alignLanguageId(fast.languageId);
|
||||||
new HdlFile(path,
|
new HdlFile(path,
|
||||||
@ -239,13 +239,8 @@ class HdlParam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async initHdlFiles(hdlFiles: AbsPath[] | Generator<AbsPath>) {
|
public async initHdlFiles(hdlFiles: AbsPath[] | Generator<AbsPath>) {
|
||||||
const pools: Promise<void>[] = [];
|
|
||||||
for (const path of hdlFiles) {
|
for (const path of hdlFiles) {
|
||||||
const p = this.doHdlFast(path);
|
await this.doHdlFast(path);
|
||||||
pools.push(p);
|
|
||||||
}
|
|
||||||
for (const p of pools) {
|
|
||||||
await p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +249,7 @@ class HdlParam {
|
|||||||
|
|
||||||
for (const hdlFile of this.getAllHdlFiles()) {
|
for (const hdlFile of this.getAllHdlFiles()) {
|
||||||
hdlFile.makeInstance();
|
hdlFile.makeInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTopModulesByType(type: string): HdlModule[] {
|
public getTopModulesByType(type: string): HdlModule[] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user