Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix performance issue on start (with huge listings/pricelist) #522

Merged
merged 1 commit into from
Mar 29, 2021

Conversation

idinium96
Copy link
Member

Doing this:

    return this.prices.findIndex(entry => entry.sku === (sku ? sku : SKU.fromObject(parsedSku)));

will make it to poorly perform the task -

image

But this:

    sku = sku ? sku : SKU.fromObject(parsedSku);
    const findIndex = this.prices.findIndex(entry => entry.sku === sku);
    return findIndex;

Surprising fast -

image

This "without delay" thing is just the debugging thing I added here:

recursiveCheckPricelist(pricelist: Entry[], withDelay = false, time?: number, showLogs = false): Promise<void> {
return new Promise(resolve => {
let index = 0;
const iteration = async (): Promise<void> => {
if (pricelist.length <= index || this.cancelCheckingListings) {
this.cancelCheckingListings = false;
return resolve();
}
if (withDelay) {
this.checkBySKU(pricelist[index].sku, pricelist[index], false, showLogs);
index++;
await sleepasync().Promise.sleep(time ? time : 200);
void iteration();
} else {
setImmediate(() => {
this.checkBySKU(pricelist[index].sku, pricelist[index]);
index++;
void iteration();
});
}
};
void iteration();
});
}

@idinium96 idinium96 changed the title 🐛 fix performance issue on start (with huge listings) 🐛 fix performance issue on start (with huge listings/pricelist) Mar 29, 2021
@idinium96 idinium96 merged commit 4750533 into development Mar 29, 2021
@idinium96 idinium96 deleted the issue-517-fix branch March 29, 2021 05:18
@idinium96 idinium96 mentioned this pull request Mar 29, 2021
idinium96 added a commit that referenced this pull request Mar 29, 2021
#524

## Changes
- 🔨 refactor (#523):
    - ⚡ possible performance improvements
    - ⏮ reverted #500
    - 🔄 updated `bptf-listings-2` library

## FIxes
- 🐛 fixed missing `%name%` parameter on `!clearfriends` command (#521) - @idinium96
- 🐛 fixed performance issue on start (with huge listings/pricelist) (#522) - @idinium96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant