[WIP] perf(Core): tweak tryFindTextOfRange - #884
Draft
Numpsy wants to merge 1 commit into
Draft
Conversation
tryFindTextOfRange appears to be a hotspot for performance in the current version (the calls to IndexOf show up at the top of profiles of the benchmark app) So, I was wondering: - If the end position is always after the first, can we look for the end line starting from the start line, rather than searching from the start of the source text every time? - If the start and end positions are on the same line, it shouldn't need to do the 'find line' run twice - I don't think there is a need to look for the end index if it can't find the start, given that the function returns None if it can't get both So - an attempt at a change - only look for the end position if we have the start - start looking for the end line starting at the offset of the start line, to reduce duplicate work (findLineStart should also then exit immediately if the start and end are on the same line)
Contributor
Author
|
A bit more musing based on this from profiling the benchmark app with the latest source:
If I run the benchmark of the current master branch with the default set of rules I get this now: But with this change I get with the changes from #877 and the extended set of rules from the self check I get this but with this change on top of that I get |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

tryFindTextOfRange appears to be a hotspot for performance in the current version (the calls to IndexOf show up at the top of profiles of the benchmark app)
So, I was wondering:
So - an attempt at a change