Repository navigation
Commit e9914e4
Optimize
In some cases `string.Split(char, ...)` was slower (significantly) than
the single `string` seperator overload - this PR optimizes the `char`
overload/s to have better performance - the single-`char` overloads are
the most common case, so I have added the additional optimisation just
for that for now - benchmarks below.
BENCHMARKS ARE OUT OF DATE
Main benchmark that was the focus - single char splitter with rare/no
seperators (~20% improvement on arm, ~47% improvement on x64) - `char`
outperforms `string` now:
X64 (AMD):
<img width="1530" height="334" alt="image"
src="https://github.com/user-attachments/assets/ad7c31b3-4220-4f3b-8349-76faf15d3d0c"
/>
Arm:
<img width="738" height="157" alt="image"
src="https://github.com/user-attachments/assets/5a3cb1b2-de37-4116-bd6d-c26eca91fb3c"
/>
Other cases have not regressed meaningfully (within margin of error).
There's still up to about 15% performance available for .NET 12:
#125379 (comment).
---------
Co-authored-by: Copilot Autofix powered by AI <[email protected]>string.Split(char, ...) (#125379)1 parent 58dfec7 commit e9914e4
3 files changed
Lines changed: 290 additions & 43 deletions
File tree
- src/libraries
- System.Private.CoreLib/src/System
- System.Runtime/tests/System.Runtime.Tests/System
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
1143 | | - | |
| 1143 | + | |
1144 | 1144 | | |
1145 | 1145 | | |
1146 | 1146 | | |
| |||
1152 | 1152 | | |
1153 | 1153 | | |
1154 | 1154 | | |
1155 | | - | |
| 1155 | + | |
1156 | 1156 | | |
1157 | 1157 | | |
1158 | 1158 | | |
| |||
1164 | 1164 | | |
1165 | 1165 | | |
1166 | 1166 | | |
1167 | | - | |
| 1167 | + | |
1168 | 1168 | | |
1169 | 1169 | | |
1170 | 1170 | | |
| |||
0 commit comments