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

Performance improvements #230

Merged
merged 1 commit into from
Sep 10, 2018
Merged

Performance improvements #230

merged 1 commit into from
Sep 10, 2018

Conversation

ilyapuchka
Copy link
Collaborator

@ilyapuchka ilyapuchka commented Sep 8, 2018

Trying to address performance issues introduced by #167

  • do not parse lines for each token, do that once when lexer is created

@ilyapuchka
Copy link
Collaborator Author

@yonaskolb if you have a chance could you please try this branch with your benchmark or add measurement tests if you have written any already?

@yonaskolb
Copy link
Collaborator

@ilyapuchka I ran the same tests again and got great results!
before: 6.42
after: 0.45

Nice work! 🎉

@ilyapuchka
Copy link
Collaborator Author

@yonaskolb thanks! seems acceptable so we can merge it then and someone makes a patch release?

@ilyapuchka
Copy link
Collaborator Author

it would be better to include some measurement tests though while we are on that, to avoid such things in future

@ilyapuchka ilyapuchka merged commit acda1b0 into master Sep 10, 2018
@ilyapuchka ilyapuchka deleted the errors-logs-improvements branch September 10, 2018 10:39
@yonaskolb yonaskolb changed the title [WIP] Performance improvements Performance improvements Sep 10, 2018
@djbe djbe added this to the 0.13.0 milestone Sep 21, 2018
@djbe djbe mentioned this pull request Sep 24, 2018

self.lines = templateString.components(separatedBy: .newlines).enumerated().flatMap {
guard !$0.element.isEmpty else { return nil }
return (content: $0.element, number: UInt($0.offset + 1), templateString.range(of: $0.element)!)
Copy link
Collaborator

@AliSoftware AliSoftware Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching up and reading that PR content a little late…

@ilyapuchka @djbe Doesn't that templateString.range(of: $0.element) introduce the risk that you get the wrong range if the template have multiple similar lines? And also, searching the whole templateString for that $0.element might take some time especially for long templateString strings?

Shouldn't we instead keep a running total of characters up to each line, and construct the range from range = (currentCharIndex..<currentCharIndex + $0.element.length) then curentCharIndex = thatRange.endIndex+1 or something similar to avoid such risk?

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

Successfully merging this pull request may close these issues.

4 participants