Skip to content

Instantly share code, notes, and snippets.

View rent-a-developer's full-sized avatar

David Liebeherr rent-a-developer

View GitHub Profile
@rent-a-developer
rent-a-developer / ActionExtensions.cs
Created June 5, 2022 21:01
An implementation of a debounce and a throttle logic in C#
/// <summary>
/// Provides extension methods for the <see cref="Action" /> type.
/// </summary>
public static class ActionExtensions
{
/// <summary>
/// Creates a debounced version of the given function <paramref name="action" />.
/// Use this method when you want a function to be executed after a certain amount of time has passed since it was called the last time.
/// </summary>
/// <param name="action">The function to debounce.</param>
@rent-a-developer
rent-a-developer / Benchmarks.cs
Created April 21, 2025 01:37
Benchmarking C# for vs for each statement (plus Span<T>)
using BenchmarkDotNet.Attributes;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Order;
namespace AutoIndexCache.Benchmarks;
[MemoryDiagnoser]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[GcServer]
public class Benchmarks