Skip to content

Instantly share code, notes, and snippets.

View MisterKidX's full-sized avatar

Dor Ben Dor MisterKidX

View GitHub Profile
@MisterKidX
MisterKidX / IEquatableComparison.cs
Last active November 21, 2022 11:39
IEquatable<T> Performance with List<T> and structs
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
int capacity = 10_000_000;
List<Vector3NoEquals> Vector3NoEquals = new(capacity);
List<Vector3WithEquals> Vector3GoodEquals = new(capacity);
List<Vector3WithIEquality> Vector3WithIEquality = new(capacity);
for (int i = 0; i < capacity; i++)
{
@MisterKidX
MisterKidX / DemonstratingIDisposable.cs
Created October 14, 2022 11:34
Demonstrates the use of IDisposable
Console.WriteLine("Creating 50 NotDisposable objects which will" +
" allocate 500mb of memory and will not clean at garbage collection.");
Console.ReadLine();
if(true)
{
NotDisposableContainer container = new NotDisposableContainer();
container.ND = new List<NotDisposable>();
for (int i = 0; i < 50; i++)
container.ND.Add(new NotDisposable());
@MisterKidX
MisterKidX / EqualityComparison.cs
Created October 13, 2022 14:38
Default equality comparison of the C# language
using System;
using System.Collections.Generic;
using System.Diagnostics;
int iterations = 1_000_000;
List<ReflectionComparison> comparisons1 = new List<ReflectionComparison>();
List<ReflectionComparison> comparisons2 = new List<ReflectionComparison>();
List<ByteComparison> comparisons3 = new List<ByteComparison>();
List<ByteComparison> comparisons4 = new List<ByteComparison>();
List<ReferenceType> comparisons5 = new List<ReferenceType>();