Optimize execution time

This commit is contained in:
Anton Vakhrushev 2020-04-25 12:46:57 +03:00
parent d4aca5162c
commit 09d97584ef
2 changed files with 14 additions and 6 deletions

View File

@ -25,12 +25,22 @@ export class Executor {
async run() {
await waitForLoad();
await sleepMicro();
markPage('Executor', this.version);
try {
markPage('Executor', this.version);
this.renderTaskQueue();
setInterval(() => this.renderTaskQueue(), 5 * 1000);
} catch (e) {
this.logger.warn(e);
}
let skipFirstSleep = true;
while (true) {
if (skipFirstSleep) {
skipFirstSleep = false;
} else {
await sleepMicro();
}
await this.doTaskProcessingStep();
}
}
@ -40,8 +50,6 @@ export class Executor {
}
private async doTaskProcessingStep() {
await sleepMicro();
const currentTs = timestamp();
const task = this.scheduler.nextTask(currentTs);

View File

@ -5,7 +5,7 @@ export function sleep(ms: number) {
}
export async function sleepMicro() {
let ms = 1000 + Math.random() * 2000;
let ms = 2000 + Math.random() * 500;
return await sleep(ms);
}