An observation / question whilst liiking at using CopyString intsead of GetString in JSONPListParser.
The reason I ask is that I made a small benchmark.net project that just loads the C# grammer and the dark theme, and with the current code (the System.Text.Json version), i get this:
| Method | Job | Runtime | Mean | Error | StdDev | Median | Gen0 | Gen1 | Allocated |
|------------------ |--------------------- |--------------------- |------------:|----------:|----------:|------------:|---------:|--------:|-----------:|
| LoadDarkPlusTheme | .NET 6.0 | .NET 6.0 | 27.84 us | 0.550 us | 0.514 us | 27.55 us | 6.5613 | 0.4883 | 40.3 KB |
| LoadCSGrammar | .NET 6.0 | .NET 6.0 | 954.05 us | 18.628 us | 27.881 us | 951.18 us | 167.9688 | 72.2656 | 1031.75 KB |
| LoadDarkPlusTheme | .NET 7.0 | .NET 7.0 | 23.26 us | 0.459 us | 0.948 us | 22.86 us | 6.5613 | 0.4883 | 40.3 KB |
| LoadCSGrammar | .NET 7.0 | .NET 7.0 | 867.26 us | 17.322 us | 38.743 us | 847.65 us | 167.9688 | 94.7266 | 1031.75 KB |
| LoadDarkPlusTheme | .NET Framework 4.7.2 | .NET Framework 4.7.2 | 48.68 us | 0.407 us | 0.340 us | 48.77 us | 6.7749 | 0.4883 | 41.79 KB |
| LoadCSGrammar | .NET Framework 4.7.2 | .NET Framework 4.7.2 | 1,608.01 us | 31.973 us | 66.739 us | 1,585.66 us | 173.8281 | 66.4063 | 1079.56 KB |
The timings are a bit variable running the test on my laptop, but the reported reduction in allocations was much larger that I expected (to the point I wondered if something else is going on, but the unit tests all pass so).
An observation / question whilst liiking at using CopyString intsead of GetString in JSONPListParser.
The reason I ask is that I made a small benchmark.net project that just loads the C# grammer and the dark theme, and with the current code (the System.Text.Json version), i get this:
but with this change I get:
The timings are a bit variable running the test on my laptop, but the reported reduction in allocations was much larger that I expected (to the point I wondered if something else is going on, but the unit tests all pass so).
Anyway, I'll leave it here for comments.