Last active
June 10, 2017 15:43
-
-
Save atsvetkov/c72c696d4c7c3c034f1f30a304f95b40 to your computer and use it in GitHub Desktop.
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BenchmarkRunner.Run<GuardBenchmark>(); | |
} | |
} | |
[MemoryDiagnoser] | |
public class GuardBenchmark | |
{ | |
private readonly SomeReferenceType _reference = new SomeReferenceType(); | |
[Benchmark] | |
public void GuardWithAllocations() | |
{ | |
Guard.NotNull(() => _reference); | |
} | |
[Benchmark] | |
public void GuardWithoutAllocations() | |
{ | |
Guard.NotNull(_reference, nameof(_reference)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment