1. Setting up an Entity Framework Model
- Create Model Classes:
public class MyFileRecord { public int Id { get; set; } public string FileName { get; set; } // You might want to track the original file name public byte[] FileData { get; set; } }
| using System.Security.Cryptography; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Reports; | |
| using BenchmarkDotNet.Running; | |
| public class Transaction | |
| { | |
| public decimal Amount { get; } | |
| public TimeSpan TransactionTime { get; } |
| using System; | |
| using System.Collections.Generic; | |
| using System.Runtime.InteropServices; | |
| using System.Threading.Tasks; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Running; | |
| BenchmarkRunner.Run<PersonAgeSumPerformanceBenchmark>(); | |
| [MemoryDiagnoser] |
| using System; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Running; | |
| public interface INumber | |
| { | |
| object NumericValue { get; set; } | |
| } | |
| public class Number : INumber |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Running; | |
| namespace YieldVsListPerformanceComparison | |
| { | |
| public class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| BenchmarkRunner.Run<PerformanceBenchmarks>(); |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Running; | |
| namespace ZeroAllocBenchmark | |
| { | |
| [MemoryDiagnoser] | |
| public class DateParsingPerformanceComparison | |
| { | |
| private const string SampleDateString = "2024-03-13"; |
| [RankColumn] | |
| public class CountVsAnyBenchmark | |
| { | |
| private List<int>? largeList; | |
| private readonly Random random = new(); | |
| [Params(100, 10000, 1000000)] | |
| public int NumberOfElements { get; set; } | |
| [GlobalSetup] |
| public sealed class ExponentialBackoff | |
| { | |
| private const double InitialDelayInSeconds = 1; | |
| private const double MaximumDelayInSeconds = 60; | |
| public static async Task<T> ExecuteWithExponentialBackoffAsync<T>(Func<Task<T>> operation, int maximumRetryAttempts = 5) | |
| { | |
| int currentRetryCount = 0; | |
| double currentDelayInSeconds = InitialDelayInSeconds; |
| using System.Collections.Concurrent; | |
| using System.Globalization; | |
| var money = new Money(1234.56m, "USD"); | |
| Console.WriteLine(money.ToString("N", new CultureInfo("en-EN"))); // 1,234.56 USD | |
| money = new Money(1234.56m, "EUR"); | |
| Console.WriteLine(money.ToString("N", new CultureInfo("de-DE"))); // 1.234,56 EUR | |
| money = new Money(1234.56m, "JPY"); |
| using System; | |
| using System.IO; | |
| namespace AKSExample | |
| { | |
| class Program | |
| { | |
| private static readonly string logFilePath = "memory_refresh_log.txt"; | |
| static void Main(string[] args) |
1. Setting up an Entity Framework Model
public class MyFileRecord
{
public int Id { get; set; }
public string FileName { get; set; } // You might want to track the original file name
public byte[] FileData { get; set; }
}