Faster IndexOf for Substrings in .NET

2
Faster IndexOf for Substrings in .NET

A draft for #60866, real to study tests on CI.

A transient benchmark:

_data.IndexOf(“walking”, StringComparison.Ordinal); // or _data.AsSpan().IndexOf()
}”>

the usage of BenchmarkDotNet.Attributes;
the usage of BenchmarkDotNet.Working;

BenchmarkSwitcher.FromAssembly(typeof(Benchmarks).Assembly).Bustle(args);

public class Benchmarks
{
    string _data = "I'm a man who walks alone and when I'm walking a...";

    [Benchmark]
    public int IndexOf() => _data.IndexOf("walking", StringComparison.Ordinal); // or _data.AsSpan().IndexOf()
}

Results:

The algorithm is in step with http://0x80.pl/articles/simd-strfind.html#algorithm-1-generic-simd


where for this particular observe “walking” we populate two 128/256bit vectors: and and note them to a recent chunk of the textual thunder material with an offset (distance betwe

Join the pack! Join 8000+ others registered users, and opt up chat, compose teams, post updates and compose chums across the enviornment!
www.knowasiak.com/register/

Leave a Reply