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 class Foo | |
{ | |
public void Bar() { } | |
} |
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
// "Inspired" by https://twitter.com/shit_sharp/status/1004360358306467844 | |
using BenchmarkDotNet.Attributes; | |
using System; | |
namespace NegativeBenchmark | |
{ | |
[MemoryDiagnoser] | |
public class NegatingNumbers | |
{ |
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
| Method | Mean | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated | | |
|------------------- |------------:|-------:|-------:|------:|------:|----------:| | |
| MapUsingInline | 11.95 ns | 1.00 | 0.0153 | - | - | 64 B | | |
| MapUsingReflection | 2,375.37 ns | 201.25 | 0.3128 | - | - | 1320 B | | |
| MapUsingAutoMapper | 132.42 ns | 11.54 | 0.0248 | - | - | 104 B | |
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; | |
namespace ConsoleApp3 | |
{ | |
[MemoryDiagnoser] | |
public class FormatQueuedTaskMessage | |
{ | |
[Benchmark] | |
[Arguments(3)] | |
[Arguments(4)] |
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
/* | |
I was curious to see what the maximum number of generic parameters were allowed for a method. | |
This was inspired by https://www.tabsoverspaces.com/233892-whats-the-maximum-number-of-arguments-for-method-in-csharp-and-in-net | |
To run this code, make a C# console application with the .csproj file looking like this: | |
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net6.0</TargetFramework> |
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; | |
public static class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine("Hello world!"); | |
} | |
} |
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
Console.WriteLine("Hello world!"); |
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 interface IDriver | |
{ | |
void Drive(); | |
} |
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 sealed class Golfer | |
: IDriver | |
{ | |
public void Drive() | |
{ | |
var value = RandomNumberGenerator.GetInt32(250, 320); | |
Console.WriteLine($"{value} yards"); | |
} | |
} |
OlderNewer