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

Parser.Parse takes around 18s to parse the 58K file #22

Closed
Metalnem opened this issue Dec 24, 2018 · 3 comments
Closed

Parser.Parse takes around 18s to parse the 58K file #22

Metalnem opened this issue Dec 24, 2018 · 3 comments

Comments

@Metalnem
Copy link

@Metalnem Metalnem commented Dec 24, 2018

Parser.Parse takes around 18s to parse the 58K file from the attached archive. You can run the following code to reproduce it (the path variable should contain the path to the extracted file):

var text = File.ReadAllText(path);
var parser = new Parser(new Lexer());
parser.Parse(new Source(text));

Found via SharpFuzz.

@sungam3r
Copy link
Contributor

@sungam3r sungam3r commented Mar 7, 2019

I can not read the file from the archive. It looks like it has binary data.

@sungam3r
Copy link
Contributor

@sungam3r sungam3r commented Mar 8, 2019

Oh, I get it. The whole point is that the file is binary and its parsing error occurs. Time is wasted on getting an error message in this method, which makes numerous extremely inefficient string replacement calls.

sungam3r added a commit to sungam3r/parser that referenced this issue Mar 8, 2019
@sungam3r
Copy link
Contributor

@sungam3r sungam3r commented Mar 8, 2019

My explanation was incorrect. The point is not even in allocations, but in the fact that the iterator for each character in the source line called Replace method, which in turn again ran over the entire line. In any case, now there are no such problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants