Skip to content

Commit ec3869b

Browse files
committed
a modest attemt
1 parent 744fa67 commit ec3869b

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/UTF8_validation.cs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,46 @@ public static unsafe class Utf8Utility
245245
// | SIMDUtf8ValidationErrorData | data/turkish.utf8.txt | 5.813 us | 0.0440 us | 0.0412 us | - |
246246

247247

248+
// if (processedLength < inputLength)
249+
// {
250+
251+
// Span<byte> remainingBytes = stackalloc byte[32];
252+
// for (int i = 0; i < inputLength - processedLength; i++)
253+
// {
254+
// remainingBytes[i] = pInputBuffer[processedLength + i];
255+
// }
256+
257+
// ReadOnlySpan<Byte> remainingBytesReadOnly = remainingBytes;
258+
// Vector256<byte> remainingBlock = Vector256.Create(remainingBytesReadOnly);
259+
// Utf8Validation.utf8_checker.CheckNextInput(remainingBlock, ref prev_input_block, ref prev_incomplete, ref error);
260+
// processedLength += inputLength - processedLength;
261+
262+
// }
263+
264+
265+
266+
267+
// | Method | FileName | Mean | Error | StdDev | Allocated |
268+
// |---------------------------- |----------------------- |----------:|----------:|----------:|----------:|
269+
// | SIMDUtf8ValidationRealData | data/arabic.utf8.txt | 31.216 us | 0.2960 us | 0.2624 us | - |
270+
// | SIMDUtf8ValidationErrorData | data/arabic.utf8.txt | 31.732 us | 0.3772 us | 0.3528 us | - |
271+
// | SIMDUtf8ValidationRealData | data/chinese.utf8.txt | 10.281 us | 0.1234 us | 0.1154 us | - |
272+
// | SIMDUtf8ValidationErrorData | data/chinese.utf8.txt | 10.370 us | 0.2019 us | 0.1889 us | - |
273+
// | SIMDUtf8ValidationRealData | data/english.utf8.txt | 12.003 us | 0.2378 us | 0.4102 us | - |
274+
// | SIMDUtf8ValidationErrorData | data/english.utf8.txt | 11.403 us | 0.1818 us | 0.1700 us | - |
275+
// | SIMDUtf8ValidationRealData | data/french.utf8.txt | 25.936 us | 0.3735 us | 0.3311 us | - |
276+
// | SIMDUtf8ValidationErrorData | data/french.utf8.txt | 22.630 us | 0.3594 us | 0.3362 us | - |
277+
// | SIMDUtf8ValidationRealData | data/german.utf8.txt | 7.186 us | 0.0220 us | 0.0195 us | - |
278+
// | SIMDUtf8ValidationErrorData | data/german.utf8.txt | 7.425 us | 0.1450 us | 0.1985 us | - |
279+
// | SIMDUtf8ValidationRealData | data/japanese.utf8.txt | 9.359 us | 0.1549 us | 0.1294 us | - |
280+
// | SIMDUtf8ValidationErrorData | data/japanese.utf8.txt | 10.929 us | 0.2096 us | 0.1961 us | - |
281+
// | SIMDUtf8ValidationRealData | data/turkish.utf8.txt | 10.493 us | 0.2098 us | 0.5708 us | - |
282+
// | SIMDUtf8ValidationErrorData | data/turkish.utf8.txt | 9.575 us | 0.1878 us | 0.1757 us | - |
248283
if (processedLength < inputLength)
249284
{
250285

251286
Span<byte> remainingBytes = stackalloc byte[32];
252-
for (int i = 0; i < inputLength - processedLength; i++)
253-
{
254-
remainingBytes[i] = pInputBuffer[processedLength + i];
255-
}
287+
new Span<byte>(pInputBuffer + processedLength, inputLength - processedLength).CopyTo(remainingBytes);
256288

257289
ReadOnlySpan<Byte> remainingBytesReadOnly = remainingBytes;
258290
Vector256<byte> remainingBlock = Vector256.Create(remainingBytesReadOnly);

0 commit comments

Comments
 (0)