Sep 25 2023
Install-Package BenchmarkDotNet
using BenchmarkDotNet.Atrributes;
public class MyBenchmarks
{
[Benchmark]
public void SomeBenchmark()
{
//Your code here...
}
}
using BenchmarkDotNet.Running;
class Program
{
static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<MyBenchmarks>();
}
}
using BenchmarkDotNet.Attributes;
public class ParameterizedBenchmarks
{
[Params(100, 200, 300)]
public int N;
[Benchmark]
public in SumUpToN()
{
int sum = 0;
for(int i=0; i < N; i++)
sum+=i;
return sum;
}
}
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
[CoreJob, ClrJob, MonoJob]
public class MultiRuntimeBenchmarks
{
[Benchmark]
public void SomeBenchmark()
{
//Your code here...
}
}
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Attributes;
public class CustomConfig : ManualConfig
{
public CustomConfig()
{
AddJob(Job.Default.WithWarmupCount(3).WithIterationCount(10));
}
}
[Config(typeof(CustomConfig))]
public class CustomConfigurationBenchmarks
{
[Benchmark]
public void SomeBenchmark()
{
//Your code here...
}
}
using BenchmarkDotNet.Attributes;
[MemoryDiagnoser]
public class MemoryDiagnosticsBenchmarks
{
[Benchmark]
public List<int> CreateList()
{
return new List<int> { 1, 2, 3, 4, 5 };
}
}
1. Design Patterns that Deliver
This isn’t just another design patterns book. Dive into real-world examples and practical solutions to real problems in real applications.Check out it here.
Go-to resource for understanding the core concepts of design patterns without the overwhelming complexity. In this concise and affordable ebook, I've distilled the essence of design patterns into an easy-to-digest format. It is a Beginner level. Check out it here.
Every Monday morning, I share 1 actionable tip on C#, .NET & Arcitecture topic, that you can use right away.
Join 14,250+ subscribers to improve your .NET Knowledge.
Subscribe to the TheCodeMan.net and be among the 14,250+ subscribers gaining practical tips and resources to enhance your .NET expertise.