Skip to content

Instantly share code, notes, and snippets.

View teoadal's full-sized avatar

Kirill Bazhaykin teoadal

View GitHub Profile
public struct LocalCache<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDisposable
where TKey : IEquatable<TKey>
{
private const int RentArrayLength = 16;
[ThreadStatic] private static Dictionary<TKey, TValue>? _cachedDictionary;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Pair[] RentArray() => ArrayPool<Pair>.Shared.Rent(RentArrayLength);
using System.Text.Json;
using System.Text.Json.Nodes;
using BenchmarkDotNet.Configs;
using Hyperbee.Json.Extensions;
using JsonCons.JsonPath;
using Newtonsoft.Json.Linq;
namespace ConsoleApp1;
[SimpleJob(RuntimeMoniker.Net90)]
using System.Collections.Frozen;
using System.Runtime.CompilerServices;
namespace ConsoleApp1;
[SimpleJob(RuntimeMoniker.Net90)]
[SimpleJob(RuntimeMoniker.Net80)]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[MeanColumn, MemoryDiagnoser]
public class HasFlagBench
using System.ComponentModel.DataAnnotations;
using BenchmarkDotNet.Order;
using Dapper;
using LinqToDB;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Npgsql;
namespace ConsoleApp1;
using System.Buffers;
using System.ComponentModel.DataAnnotations;
using BenchmarkDotNet.Order;
using Dapper;
using LinqToDB;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Npgsql;
namespace ConsoleApp1;

BenchmarkDotNet v0.14.0, Windows 11 (10.0.22621.4037/22H2/2022Update/SunValley2)
Intel Xeon CPU E5-2697 v3 2.60GHz, 2 CPU, 56 logical and 28 physical cores
.NET SDK 9.0.100
  [Host]   : .NET 8.0.10 (8.0.1024.46610), X64 RyuJIT AVX2
  .NET 9.0 : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2

Job=.NET 9.0  Runtime=.NET 9.0  
using BenchmarkDotNet.Order;
using ClosedXML.Excel;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using MiniExcelLibs;
using NPOI.HSSF.UserModel;
using OfficeOpenXml;
using SpreadCheetah;
using Cell = SpreadCheetah.Cell;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ConcurrencyToolkit.Pooling;
using Microsoft.Extensions.ObjectPool;
namespace Bench;
[SimpleJob(RuntimeMoniker.Net80)]
[MeanColumn, MemoryDiagnoser]
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Benchmarks.CollectionBenchmarks;
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Benchmarks.CollectionBenchmarks;
[SimpleJob(RuntimeMoniker.Net80)]
[MeanColumn, MemoryDiagnoser]
public class ArrayCopy