Skip to content

Instantly share code, notes, and snippets.

@Tornhoof
Tornhoof / PerTenantLifestyle.cs
Last active August 10, 2016 14:32
Tenant lifestyle
using System;
using System.Collections.Concurrent;
using System.Linq.Expressions;
using System.Reflection;
using SimpleInjector;
namespace PerTenantLifestyle
{
/// <summary>
/// Special Lifestyle for per tenant objects, basically a singleton per tenant pattern
@Tornhoof
Tornhoof / MultiTenantSimpleInject.cs
Last active August 10, 2016 18:59
MultiTenantSimpleInject
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Security.Claims;
using System.Threading;
using SimpleInjector;
namespace MultiTenantSimpleInject
{
class Program
@Tornhoof
Tornhoof / NameOfBench.cs
Created June 22, 2017 16:38
Nameof vs. Expression Tree Member Names Benchmark
``` ini
BenchmarkDotNet=v0.10.8, OS=Windows 10 Redstone 2 (10.0.15063)
Processor=Intel Core i7-4790K CPU 4.00GHz (Haswell), ProcessorCount=8
Frequency=3906243 Hz, Resolution=256.0005 ns, Timer=TSC
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.7.2098.0
DefaultJob : Clr 4.0.30319.42000, 64bit RyuJIT-v4.7.2098.0
```
@Tornhoof
Tornhoof / JilvsUtf8JsonBenchmark.md
Created September 27, 2017 20:39
Jil vs. Utf8Json Benchmark

tl;dr: With more realistic models with diverse length and types there is no clear winner. With Allocations Utf8Json wins.

Input: The models from Jil.Benchmark: https://github.com/kevin-montrose/Jil/tree/master/Benchmark/Models and ported it (with a few changes) to Benchmark.NET https://github.com/Tornhoof/Jil/tree/master/Benchmark

BenchmarkDotNet=v0.10.9, OS=Windows 10 Redstone 2 (10.0.15063)
Processor=Intel Core i7-4790K CPU 4.00GHz (Haswell), ProcessorCount=8
Frequency=3906248 Hz, Resolution=256.0001 ns, Timer=TSC
 [Host] : .NET Framework 4.7 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.2110.0
@Tornhoof
Tornhoof / JilvsUtf8JsonBenchmark-NoStringConv.md
Last active September 28, 2017 08:49
Jil vs. Utf8Json Benchmark (without string conversion for Utf8Json)

tl;dr: With more realistic models with diverse length and types there is no clear winner. For allocations Utf8Json wins. This run does not convert to string for Utf8Json but returns a byte-array and uses a byte-array for deserialization too. Jil remains with strings.

Input: The models from Jil.Benchmark: https://github.com/kevin-montrose/Jil/tree/master/Benchmark/Models and ported it (with a few changes) to Benchmark.NET https://github.com/Tornhoof/Jil/tree/master/Benchmark

BenchmarkDotNet=v0.10.9, OS=Windows 10 Redstone 2 (10.0.15063)
Processor=Intel Core i7-4790K CPU 4.00GHz (Haswell), ProcessorCount=8
Frequency=3906248 Hz, Resolution=256.0001 ns, Timer=TSC
 [Host] : .NET Framework 4.7 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.2110.0
@Tornhoof
Tornhoof / roaringbitmap.md
Last active December 15, 2017 14:04
.NET Core Performance Improvements

CensusIncome

BenchmarkDotNet=v0.10.11, OS=Windows 10 Redstone 3 [1709, Fall Creators Update] (10.0.16299.64)
Processor=Intel Core i7-4790K CPU 4.00GHz (Haswell), ProcessorCount=8
Frequency=3906248 Hz, Resolution=256.0001 ns, Timer=TSC
.NET Core SDK=2.2.0-preview1-007813
  [Host]            : .NET Core 2.1.0-preview1-26013-05 (Framework 4.6.26013.03), 64bit RyuJIT
  Core2.0-x64       : .NET Core 2.0.3 (Framework 4.6.25815.02), 64bit RyuJIT
 Core2.1-x64 : .NET Core 2.1.0-preview1-26013-05 (Framework 4.6.26013.03), 64bit RyuJIT
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using BenchmarkDotNet.Attributes;
namespace PopCountBenchmark
{
public class Benchmark
{
@Tornhoof
Tornhoof / FixProjects.cs
Created August 21, 2017 15:14
Converts Project references
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
namespace FixProjectFormat
@Tornhoof
Tornhoof / Loader.cs
Last active March 23, 2018 19:45
AssemblyLoadContext and Nuget
public class Loader
{
public static string ApplicationPath => AppDomain.CurrentDomain.BaseDirectory;
public const string ValidLibraryName = "MyLibs";
public static IEnumerable<Assembly> MatchingAssemblies =>
AppDomain.CurrentDomain.GetAssemblies().Where(x => IsValidLibrary(x.FullName));
public static Type[] Types { get; } = GetAllTypesInternal();
@Tornhoof
Tornhoof / Benchmark.cs
Last active April 5, 2018 06:41
Benchmark Integer Formatting
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace FormatIntegerPerformance
{
class Program
{
static void Main(string[] args)