-
Notifications
You must be signed in to change notification settings - Fork 16
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
Features/emumeration optimizations #35
Merged
chalcolith
merged 26 commits into
chalcolith:main
from
steve7411:features/emumeration-optimizations
May 27, 2021
Merged
Features/emumeration optimizations #35
chalcolith
merged 26 commits into
chalcolith:main
from
steve7411:features/emumeration-optimizations
May 27, 2021
Conversation
This file contains 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
Adding tests for Slice and fixing some bugs in it to make tests pass
… dotnet exec and copying exe or dll depending on the os
… enumerable can be indexed
… empty slice or segment
…> instead of a slice. This sped up the benchmark by between 14% - 30%.
… special cases of source types and always using a Slice for non-ILists in MatchItem so it always has an IList to work with
Sweet, thanks @steve7411! May I ask how you found IronMeta and what you're using it for? |
I read about it in an article I found when I was searching for C# parser generators. I'd never heard of OMeta before, and it looked nice. I'm currently using it for an interpreter for a very old version of BASIC that was originally for CP/M. |
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.
These changes reduce an O(n^2) enumeration for the common case of string inputs to O(n), amongst a few other things. I changed MatchState to create a Slice in any case where the input isn't already an IList, and Slice is now a thin wrapper around adapters that implement IList. I tried not to change publicly exposed API much, but MatchState's Input property is read only and I didn't keep Slice's copy on write since it isn't currently used anywhere.
The benchmark project is currently just using the Calc sample parser, so it's mostly exercising input classes and string input, but I was able to get a good increase in performance with these changes on an input with around 10,000 numbers:
Before:
After: