Skip to content

Instantly share code, notes, and snippets.

View john-h-k's full-sized avatar

John Kelly john-h-k

View GitHub Profile
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static unsafe void FastFill<T>(this Span<T> span, T value)
{
int size = Helpers.RuntimeSizeof<T>();
if (Avx2.IsSupported)
{
if ((size & (size - 1)) == 0 && size < 32)
{
// Is pow of 2
[CoreJob(true)]
[RPlotExporter]
[RankColumn]
public class FillBenchmark
{
public readonly object[] RefArray = new object[4096];
public readonly byte[] ByteArray = new byte[4096];
public readonly int[] Int32Array = new int[4096];
[GlobalSetup]
// Ran with
internal unsafe class Program
{
public static void Main()
{
BenchmarkRunner.Run<CopySignBenchmark>();
}
}
[CoreJob]
public class CopySignDBenchmark
{
public enum SignType
{
Random,
Same,
Different,
Alternating
}
[CoreJob]
public class CopySignSingleBenchmark
{
public enum SignType
{
Random,
Same,
Different,
Alternating
}
/// <summary>
/// Fills the contents of this span with the given value.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Fill<T>(this Span<T> @this, T value)
{
if (@this.IsEmpty)
{
return;
}
x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x * sqrt(x) * x
public struct Vector2S
{
public Vector2S(float xy)
{
X = xy;
Y = xy;
}
public Vector2S(float x, float y)
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace MathSharp.Interactive
{
internal class Program
@john-h-k
john-h-k / MathIdea.cs
Last active October 25, 2019 14:40
Math Idea
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
namespace MathExample
{
public enum Precision
{
Exact,