Skip to content

Instantly share code, notes, and snippets.

View xoofx's full-sized avatar
🏠
Working from home

Alexandre Mutel xoofx

🏠
Working from home
View GitHub Profile
@xoofx
xoofx / UUIDv7Fast.cs
Created June 16, 2024 05:11
UUIDv7Fast.cs
// From a discussion on mastodon https://mastodon.social/@antonz@c.im/112620103070756332
// This version:
// * simplifies the setup (an inline array is already a Span)
// * uses BinaryPrimitives.ReverseEndianness to batch writing the long to the buffer
// * uses SkipLocalsInit on the ctor to avoid some zero init
// Should be ~ 15% faster than the revised version with Span
// Anyway most of the time is spent in DateTimeOffset.UtcNow and RandomNumberGenerator.Fill
using System.Buffers.Binary;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
@xoofx
xoofx / BatchSimdDot.cs
Created September 2, 2024 06:36
BatchSimdDot Example
// Comment about https://mastodon.social/@brandewinder@hachyderm.io/113064780292323247
// https://brandewinder.com/2024/09/01/should-i-use-simd-vectors/
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
public class VectorProcessor
{
public static float Take2(float[] left, float[] right)
{