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

Optimize JSZhuyinDataPackStorage#_getIncompleteMatchedSingleCodesInBlock #24

Open
timdream opened this issue Dec 8, 2015 · 2 comments

Comments

@timdream
Copy link
Owner

timdream commented Dec 8, 2015

Chrome DevTools Profiler has identified JSZhuyinDataPackStorage#_getIncompleteMatchedSingleCodesInBlock as the top offender -- the for loop should be optimized if possible.

@timdream
Copy link
Owner Author

Fixing this and #25 probably means implementing the properly B-tree data structure...

@timdream
Copy link
Owner Author

timdream commented Jan 21, 2017

The current approach can be found in no-linear-search branch. The commits removes the linear for loop when search each of the block (i.e. the _getIncompleteMatchedSingleCodesInBlock function stated on the title of the issue), and search all the partial matching sounds by generate a list of matched completed sounds first.

Unfortunately, per benchmark test, that actually makes it slower by ~35%.

The next thing to try would be try to reduce the list of completed sounds, since there are 4095 combinations yet in our database per my last investigation there are only around 1001 sounds exists. Implement that might reduce 76% of our call to the _searchBlock() functions.

B-tree probably won't help here since it only re-orders the values within the linear array, not actually change how we search things within it. But that could still be the next thing to try if the previous attempt proves unhelpful.

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

No branches or pull requests

1 participant