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

Investigate using Span<char> for tokenizer/readers etc #66

Open
pjoiner opened this issue Feb 7, 2023 · 4 comments
Open

Investigate using Span<char> for tokenizer/readers etc #66

pjoiner opened this issue Feb 7, 2023 · 4 comments

Comments

@pjoiner
Copy link
Owner

pjoiner commented Feb 7, 2023

For netstandard2.0 support use System.Memory

@pjoiner
Copy link
Owner Author

pjoiner commented Oct 23, 2023

See if this can help dotnet/aspnetcore#46098

@pjoiner
Copy link
Owner Author

pjoiner commented Oct 23, 2023

Also, see this dotnet/aspnetcore#49714. Although not sure we'll be able to use this in netstandard

@pjoiner
Copy link
Owner Author

pjoiner commented Oct 28, 2023

So the issue here is that ReadOnlySpan cannot be used in an iterator block

See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs4013?f1url=%3FappId%3DDev16IDEF1%26l%3DEN-US%26k%3Dk(CS4013)%26rd%3Dtrue

Need to investigate if greedy parsing of every line using ReadOnlySpan is more efficient than lazy parsing using string.

@pjoiner
Copy link
Owner Author

pjoiner commented Oct 28, 2023

So just converting to ReadOnlySpan and using slice ToString makes no difference

|         Method |            Runtime |     Mean |     Error |    StdDev |
|--------------- |------------------- |---------:|----------:|----------:|
| TokenizeString |           .NET 5.0 | 1.428 us | 0.3652 us | 0.0200 us |
| TokenizeString |           .NET 6.0 | 1.174 us | 0.0360 us | 0.0020 us |
| TokenizeString |           .NET 7.0 | 1.241 us | 1.0689 us | 0.0586 us |
| TokenizeString | .NET Framework 4.8 | 1.449 us | 0.4930 us | 0.0270 us |

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

No branches or pull requests

1 participant