This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net8.0</TargetFramework> | |
<ImplicitUsings>enable</ImplicitUsings> | |
<Nullable>enable</Nullable> | |
</PropertyGroup> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "BenchmarkDotNet" | |
void Main() | |
{ | |
RunBenchmark(); | |
} | |
public List<int> _list = Enumerable.Range(1, 1_000_000).ToList(); | |
public int[] _array = Enumerable.Range(1, 1_000_000).ToArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "BenchmarkDotNet" | |
void Main() | |
{ | |
// Second, it adds a call to RunBenchmark (defined in BenchmarkDotNet.linq) | |
RunBenchmark(); | |
} | |
[Benchmark] | |
public void SuperLinqCountDown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkRunner.Run<Benchmark>(); | |
[SimpleJob(RuntimeMoniker.Net60)] | |
[SimpleJob(RuntimeMoniker.Net70)] | |
[MemoryDiagnoser] | |
public class Benchmark | |
{ | |
private readonly string[] _inputs = Enumerable.Range(0, 100).Select(_ => Random.Shared.Next(0, 1000).ToString()).ToArray(); | |
[Benchmark] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SequentialGuid | |
{ | |
private static long s_high; | |
private static long s_low; | |
private static volatile int s_lockFlag; | |
private const int Unintialized = 0; | |
private const int Initializing = 1; | |
private const int Initialized = 2; | |
private const int Waiting = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nullable enable | |
string? LongestCommonSubstring(string a, string b, int minLength) | |
{ | |
var sa = a.AsSpan(); | |
var sb = b.AsSpan(); | |
var prevRow = new int[b.Length]; | |
var curRow = new int[b.Length]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async IAsyncEnumerable<TTarget> SelectBoundedProducer( | |
IEnumerable<TSource> enumerable, | |
Func<TSource, Task<TTarget>> projection, | |
int maxConcurrency, | |
CancellationToken token = default) | |
{ | |
var tasks = new List<Task<TTarget>>(maxConcurrency); | |
var enumeration = enumerable.GetEnumerator(); | |
while (enumeration.MoveNext()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"1,2,1,1,0,3,1,0,0,2,4,1,0,0,0,0,2,1,0,3,1,0,0,0,6,1,3,0,0,0" | |
.Split(',') | |
.Select(x => Convert.ToInt32(x)) | |
.Segment((cur, prev, idx) => cur != prev) | |
.Where(x => x.First() == 0) | |
.Select(x => x.Count()) | |
.Max() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UserSettings> | |
<ApplicationIdentity version="15.0"/> | |
<ToolsOptions> | |
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/> | |
</ToolsOptions> | |
<Category name="Environment_Group" RegisteredName="Environment_Group"> | |
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package"> | |
<PropertyValue name="Version">2</PropertyValue> | |
<FontsAndColors Version="2.0"> | |
<Theme Id="{1DED0138-47CE-435E-84EF-9EC1F439B749}"/> |