Skip to content

Instantly share code, notes, and snippets.

View EgorBo's full-sized avatar
🛠️
Working from home

Egor Bogatov EgorBo

🛠️
Working from home
View GitHub Profile
@EgorBo
EgorBo / Benchmarks.cs
Last active January 9, 2022 21:59
Benchmarks.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
static class Program
{
static void Main(string[] args)
{
BenchmarkSwitcher.FromAssembly(typeof(MainBenchmarks).Assembly).Run(args);
}
}
@EgorBo
EgorBo / SimpleBenchmarks.txt
Created January 9, 2022 21:22
SimpleBenchmarks.txt
| Method | Job | Toolchain | Mean | Error | StdDev | Ratio |
|------------ |----------- |----------------------------:|----------:|----------:|----------:|------:|
| IndexOf | Job-OHKTCB | \Core_Root_Base\corerun.exe | 33.219 ns | 0.0815 ns | 0.0636 ns | 1.00 |
| IndexOf | Job-QKMCMY | \Core_Root_EGOR\corerun.exe | 16.176 ns | 0.0254 ns | 0.0238 ns | 0.49 |
| | | | | | | |
| LastIndexOf | Job-OHKTCB | \Core_Root_Base\corerun.exe | 31.953 ns | 0.0232 ns | 0.0217 ns | 1.00 |
| LastIndexOf | Job-QKMCMY | \Core_Root_EGOR\corerun.exe | 15.704 ns | 0.0374 ns | 0.0312 ns | 0.49 |
| | | | | | | |
| Contains | Job-OHKTCB | \Core_Root_Base\corerun.exe | 27.097 ns | 0.0301 ns | 0.0235 ns | 1.00 |
@EgorBo
EgorBo / MainBenchmarks.txt
Created January 9, 2022 21:20
MainBenchmarks.txt
Job-PEQKNF : .NET 7.0.0 (42.42.42.42424), X64 RyuJIT
WarmupCount=30
| Method | Toolchain | source | str | Mean | Error | StdDev | Median | Ratio |
|------------ |-----------------------------|--------------------- |----------------- |-----------:|----------:|----------:|-----------:|------:|
| IndexOf | \Core_Root_Base\corerun.exe | <html(...)html> [60] | </hhhh> | 50.478 ns | 0.0415 ns | 0.0368 ns | 50.474 ns | 1.00 |
| IndexOf | \Core_Root_EGOR\corerun.exe | <html(...)html> [60] | </hhhh> | 15.091 ns | 0.0092 ns | 0.0081 ns | 15.090 ns | 0.30 | 👍
| | | | | | | | | |
| LastIndexOf | \Core_Root_Base\corerun.exe | <html(...)html> [60] | </hhhh> | 43.979 ns | 0.0783 ns | 0.0732 ns | 43.970 ns | 1.00 |
@EgorBo
EgorBo / FasterHttpHeadersParse.cs
Last active December 27, 2021 20:16
FasterHttpHeadersParse.cs
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using System.Text;
public class Prog
@EgorBo
EgorBo / AVX-string-eq-inlined.cs
Last active December 22, 2021 15:49
AVX-string-eq-inlined.cs
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
//| Method | headerName | Mean | Error | StdDev | Ratio |
//|----------------- |------------------- |---------:|----------:|----------:|------:|
@EgorBo
EgorBo / Faster_SpanHelpers_IndexOf.cs
Last active December 22, 2021 11:07
Faster_SpanHelpers_IndexOf.cs
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Text;
using BenchmarkDotNet.Attributes;
@EgorBo
EgorBo / sse-vs-avx-string-equals.cs
Last active December 20, 2021 18:20
sse-vs-avx-string-equals.cs
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
//BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19042.1415 (20H2/October2020Update)
//Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
@EgorBo
EgorBo / rangecheck-generator.cs
Created December 19, 2021 22:06
rangecheck-generator.cs
using System;
using System.IO;
static class Program
{
static void WL(string str) => File.AppendAllText(@"C:\prj\t.cs", str + Environment.NewLine);
static void Main()
{
string[] values =
@EgorBo
EgorBo / AllocateUninitializedString.cs
Created December 13, 2021 21:26
AllocateUninitializedString.cs
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
public class Program
{
static ref byte GetRawData(object obj) =>
ref Unsafe.As<RawData>(obj).Data;
[StructLayout(LayoutKind.Sequential)]
@EgorBo
EgorBo / b.cs
Last active December 13, 2021 18:39
b.cs
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
public interface IInterface1 { IInterface2 GetInterface(); }
public interface IInterface2 { IInterface3 GetInterface(); }
public interface IInterface3 { IInterface4 GetInterface(); }
public interface IInterface4 { void SayHello(); }