Skip to content

Instantly share code, notes, and snippets.

@atsvetkov
Last active June 10, 2017 15:43
Show Gist options
  • Save atsvetkov/c72c696d4c7c3c034f1f30a304f95b40 to your computer and use it in GitHub Desktop.
Save atsvetkov/c72c696d4c7c3c034f1f30a304f95b40 to your computer and use it in GitHub Desktop.
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