graphql-dotnet/parser

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

Metalnem opened this issue · 3 comments

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.

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

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.

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.