Skip to content

Instantly share code, notes, and snippets.

View sakno's full-sized avatar
🎯
Focusing

SRV sakno

🎯
Focusing
View GitHub Profile
@sakno
sakno / memory-streaming-bench.cs
Last active December 21, 2020 12:54
Demonstrates performance measurements of MemoryStream, RecyclableMemoryStream and SparseBuffer
using System;
using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Order;
using Microsoft.IO;
namespace DotNext.Buffers
{
using IO;
@sakno
sakno / mtu_discovery.md
Last active April 11, 2020 16:10
Path MTU discovery in C#

The following code allows to discover MTU between your local machine and remote host in C#:

static int? DiscoverMtu(IPAddress address, int timeout, int ttl = 240)
        {
            const int icmpEchoHeaderSize = 8;
            const int mtuMinSize = 60;
            const int mtuMaxSize = 65500;
            int mtuLowerBound = mtuMinSize, mtuUpperBound = mtuMaxSize;
            var bestMtu = default(int?);
            using var ping = new Ping();
@sakno
sakno / roslyn-tc-proposal.md
Last active March 25, 2019 16:28
Roslyin Compiler Support for Type Classes

Roslyin Compiler Support for Type Classes

This documentation describes potential implementation of Type Classes and Shapes features in Roslyn compiler.

Goals:

  1. Provide a solution without extra modification of .NET CLR
  2. Stay backward compatible so previous versions of C# programming language can use generic types constrained with type classes
  3. Stay CLS compliant
  4. Provide interoperability between different .NET languages