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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Running; | |
using System; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
BenchmarkRunner.Run<PunBench>(); |
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System; | |
using System.Threading.Tasks; | |
#if DEBUG | |
var obj = new AsyncMachineryBenchmarks(); | |
// we should have done 100 things (just yields) either way |
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System.Buffers; | |
using System.Text.Json; | |
// prove impl | |
var obj = new MyBench { Count = 5 }; | |
obj.Init(); | |
Console.WriteLine(obj.Payload); | |
Console.WriteLine(string.Join(',', obj.Linq())); |
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System.Numerics; | |
BenchmarkRunner.Run(typeof(ConcatBenchmark).Assembly); | |
[MemoryDiagnoser] | |
public class ConcatBenchmark | |
{ | |
private readonly int[] arr1 = new[] { 1, 2, 3, 4, 5, 0 }, |
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
var sb = new StringBuilder("select name from person"); | |
if (!string.IsNullOrWhiteSpace(name)) | |
{ | |
sb.Append(" where name = @name"); | |
} | |
var sql = sb.ToString(); | |
foreach (var row in connection.Query<string>(sql, new { name})) | |
{ | |
Console.WriteLine(row); | |
} |
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
using System; | |
using System.Runtime.CompilerServices; | |
Bar b = CreateBar(42); // invoke a private .ctor | |
ref int x = ref GetBarX(b); // read field *ref* | |
Console.WriteLine(x); // deref field value | |
x = 17; // rewrite a private readonly field | |
Console.WriteLine(b.A); // 17 | |
[UnsafeAccessor(UnsafeAccessorKind.Constructor)] |
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System.Collections.Frozen; | |
using System.Collections.ObjectModel; | |
BenchmarkRunner.Run(typeof(DictionaryTests).Assembly, args: args); | |
[MemoryDiagnoser] | |
public class DictionaryTests | |
{ |
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
Test: pass | |
hash took 0.000879 seconds; 16384 unique values | |
Press any key to show results... | |
0: cc18 | |
1: d979 | |
2: e6db | |
3: f3ba | |
4: dd96 | |
5: c8f7 | |
6: f755 |
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
using System; | |
using System.Diagnostics; | |
using System.Text; | |
using System.Threading; | |
static class P { | |
static int remainingKeys = Crc16.RedisClusterSlotCount; | |
static readonly string[] keys = new string[remainingKeys]; | |
const byte CharsStart = 33, // ignore space | |
CharsEnd = 126; // ignore DEL |
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System; | |
using System.Runtime.CompilerServices; | |
BenchmarkRunner.Run<SkipLocalsInitBenchmark>(); | |
[SimpleJob] | |
public unsafe class SkipLocalsInitBenchmark | |
{ |
NewerOlder