Skip to content

Instantly share code, notes, and snippets.

@bellons91
bellons91 / benchmark.cs
Created January 30, 2024 13:29
Performance benchmark of Catch + When vs Catch + If-Else
[MemoryDiagnoser]
public class TryCatchWhenBenchmark
{
[Params(100, 10_000, 100_000)]
public int Size;
[Benchmark]
public void WithIfElse()
{
for (int i = 0; i < Size; i++)
@bellons91
bellons91 / Open-multi-browser.ps1
Created July 9, 2023 13:50
Open same URL in multiple browsers
$entity ="team-logo";
$id="nba@2020@3425";
$devEnv ="https://host-import-api.sinclair-test.deltatre.digital/api/Editorial";
$localEnv ="https://localhost:44317/api/Editorial";
Invoke-Expression “cmd.exe /C start $($devEnv)/$($entity)/$($id)"
Invoke-Expression “cmd.exe /C start $($localEnv)/$($entity)/$($id)"
@bellons91
bellons91 / Open-all-endpoints.ps1
Created July 9, 2023 13:49
Open all endpoints
$baseUrl ="https://localhost:44383/api/v1";
$pages =
"/league/league-nba",
"/season/dir__league-nba",
"/season/season-nba-55467",
@bellons91
bellons91 / string-isnullorempty-vs-isnullorwhitespace-trim.cs
Created July 9, 2023 13:46
IsNullOrEmpty and Trim vs IsNullOrWhitespace
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<StringEmptyTrimPerformance>();
}
[MemoryDiagnoser]
public class StringEmptyTrimPerformance
{
private List<string> items;
@bellons91
bellons91 / string-isnullorempty-vs-isnullorwhitespace.cs
Created July 9, 2023 13:45
IsNullOrEmpty vs IsNullOrWhitespace
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<StringNullOrEmptyPerformance>();
}
[MemoryDiagnoser]
public class StringNullOrEmptyPerformance
{
private List<string> items;
@bellons91
bellons91 / string-concat-vs-stringbuilder.cs
Created July 9, 2023 13:44
String concat vs StringBuilder
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<StringConcatenationPerformance>();
}
[MemoryDiagnoser]
@bellons91
bellons91 / sort-vs-orderby.cs
Created July 9, 2023 13:43
Sort() vs OrderBy() benchmark
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<SortVsOrderbyPerformance>();
}
[MemoryDiagnoser]
public class SortVsOrderbyPerformance
{
private List<int> itemsForSort = new List<int>();
@bellons91
bellons91 / list-with-size-benchmark.cs
Created July 9, 2023 13:43
List with resize Benchmark
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<ListCapacityPerformance>();
}
[MemoryDiagnoser]
public class ListCapacityPerformance
{
@bellons91
bellons91 / hashset-count-benchmark.cs
Created July 9, 2023 13:42
Hashset .Count vs .Count() benchmark
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<HashSetPerformance>();
}
public class HashSetPerformance
{
private HashSet<int> set;
@bellons91
bellons91 / distinct-vs-hashset-benchmark.cs
Created July 9, 2023 13:41
Distinct vs HashSet benchmark
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<DuplicatePerformance>();
}
[MemoryDiagnoser]
public class DuplicatePerformance
{
private List<int> items;