Skip to content

Instantly share code, notes, and snippets.

Adam Sitnik adamsitnik

Block or report user

Report or block adamsitnik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adamsitnik
adamsitnik / example.cs
Created Sep 23, 2019
params_valuetuples
View example.cs
public class StringHash
{
public static IEnumerable<(CultureInfo CultureInfo, CompareOptions CompareOptions)> GetOptions()
{
// Ordinal and OrdinalIgnoreCase use single execution path for all cultures, so we test it only for "en-US"
yield return (new CultureInfo("en-US"), CompareOptions.Ordinal);
yield return (new CultureInfo("en-US"), CompareOptions.OrdinalIgnoreCase);
yield return (new CultureInfo("en-US"), CompareOptions.None);
yield return (new CultureInfo("en-US"), CompareOptions.IgnoreCase);
@adamsitnik
adamsitnik / Benchmarks.csproj
Last active Aug 26, 2019
How to compare local changes vs nuget package using single BDN config
View Benchmarks.csproj
<Project Sdk="Microsoft.NET.Sdk">
<!-- IMPORTANT! MSBuild sets the Optimize=true only if the Configuration name == Release -->
<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
<ProjectReference Include="SomeProject.csproj" />
</ItemGroup>
View speedscope.json
{"exporter": "speedscope@1.3.2", "name": "blog2_full.speedscope", "activeProfileIndex": 0, "$schema": "https://www.speedscope.app/file-format-schema.json", "shared": { "frames": [ { "name": "Process64 ABABABABABA (19392) Args: " }, { "name": "Thread (9076) CPU=1300ms (Startup Thread)" }, { "name": "ntdll!RtlUserThreadStart" }, { "name": "ntoskrnl!KiStartUserThreadReturn" }, { "name": "ntoskrnl!KiStartUserThread" }, { "name": "ntoskrnl!PspUserThreadStartup" }, { "name": "ntoskrnl!DbgkCreateThread" }, { "name": "ntoskrnl!PsCallImageNotifyRoutines" }, { "name": "mssecflt!?" }, { "name": "fltmgr!FltCreateFileEx" }, { "name": "fltmgr!FltpCreateFile" }, { "name": "ntoskrnl!IoCreateFileEx" }, { "name": "ntoskrnl!IopCreateFile" }, { "name": "ntoskrnl!ObOpenObjectByNameEx" }, { "name": "ntoskrnl!ObpLookupObjectName" }, { "name": "ntoskrnl!IopParseDevice" }, { "name": "ntoskrnl!IoCallDriverWithTracing" }, { "name": "ntoskrnl!IofCallDriver" }, { "name": "fltmgr!FltpCreate" }, { "name": "fltmgr!FltpLegacyProcessingAfterP
@adamsitnik
adamsitnik / simple_example.json
Created Jan 6, 2019
Simple SpeedScope example
View simple_example.json
{"exporter": "speedscope@1.3.2", "name": "simple_example", "activeProfileIndex": 0, "$schema": "https://www.speedscope.app/file-format-schema.json", "shared": { "frames": [ { "name": "Process64 ConsoleApp18 (16156) Args: " }, { "name": "Thread (21900) CPU=348ms (Startup Thread)" }, { "name": "ntdll!RtlUserThreadStart" }, { "name": "ntoskrnl!KiStartUserThreadReturn" }, { "name": "ntoskrnl!KiStartUserThread" }, { "name": "ntoskrnl!PspUserThreadStartup" }, { "name": "ntoskrnl!DbgkCreateThread" }, { "name": "ntoskrnl!PsCallImageNotifyRoutines" }, { "name": "mssecflt!?" }, { "name": "fltmgr!FltCreateFileEx" }, { "name": "fltmgr!FltpCreateFile" }, { "name": "ntoskrnl!IoCreateFileEx" }, { "name": "ntoskrnl!IopCreateFile" }, { "name": "ntoskrnl!ObOpenObjectByNameEx" }, { "name": "ntoskrnl!ObpLookupObjectName" }, { "name": "ntoskrnl!IopParseDevice" }, { "name": "ntoskrnl!IoCallDriverWithTracing" }, { "name": "ntoskrnl!IofCallDriver" }, { "name": "fltmgr!FltpCreate" }, { "name": "fltmgr!FltpPassThroughInternal" }, { "n
View Boilerplate.cs
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using BenchmarkDotNet.Attributes;
namespace BenchmarkDotNet.Samples
{
public class MathNano
{
View Benchmarks.cs
using System;
using System.Linq;
using System.Threading;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Running;
View DebugVsRelease.cs
public class DebugVsRelease : ManualConfig
{
public DebugVsRelease()
{
IToolchain toolchain = // to rebuild the project we need to use the CsProj toolchain not the Roslyn one (the default for .NET)
#if NETFRAMEWORK
CsProjClassicNetToolchain.Current.Value;
#else
CsProjCoreToolchain.Current.Value;
View Consumer.cs
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Benchmarks
{
public class Consumer
{
private volatile byte byteHolder;
private volatile sbyte sbyteHolder;
View CollectionBenchmarks.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Linq;
namespace ConcreteVsAbstract
{
class Program
{
static void Main(string[] args) => BenchmarkRunner.Run<Benchmarks>();
View sampleProfilerinteggration.cs
namespace BenchmarkDotNet.Samples
{
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<TheTypeWithBenchmarks>(DefaultConfig.Instance.With(new SampleIntegrationWithProfiler()));
}
}
You can’t perform that action at this time.