-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add a Lines(this string) extensions method #52
Conversation
For benchmarks I'd think having N vary by a factor of 10 (like you did in your recent video) would be more useful than values of 1/5/10/15, just FYI |
{ | ||
public static void Main(string[] args) | ||
{ | ||
var summary = BenchmarkRunner.Run<LinesBenchmarks>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider ensuring benchmark methods return identical results
/// Assert.False(lines.MoveNext()); | ||
/// </code> | ||
/// </example> | ||
public static IEnumerable<ReadOnlyMemory<char>> Lines(this string text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you include a code example in the XML comments!
This method is inspired by rust's
String.lines()
method.I've decided to make this method return a
IEnumerable<ReadOnlyMemory<char>>
instead of anIEnumerable<string>
because there is a non-negligeable performance gain in doing so.I've compared three different ways of splitting a string on new lines, here are the benchmarks: