Skip to content

Instantly share code, notes, and snippets.

View tannergooding's full-sized avatar

Tanner Gooding tannergooding

View GitHub Profile
@tannergooding
tannergooding / Sample.cs
Last active August 6, 2016 04:30
Simple Benchmark for Buffer.MemoryCopy
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
unsafe class Program
{
const int outerIterations = 10000;
const int innerIterations = 10000;
@tannergooding
tannergooding / Assembly_x64.asm
Last active August 6, 2016 17:41
MemMove using XMM and optimized block copy.
00007FF953D04AC3 mov rdx,r8
00007FF953D04AC6 cmp rdx,10h
00007FF953D04ACA ja 00007FF953D04C43
00007FF953D04AD0 movsxd rdx,edx
00007FF953D04AD3 cmp rdx,10h
00007FF953D04AD7 ja 00007FF953D04C43
00007FF953D04ADD lea r8,[7FF953D04E18h]
00007FF953D04AE4 mov r8d,dword ptr [r8+rdx*4]
00007FF953D04AE8 lea rax,[7FF953D04AC3h]
00007FF953D04AEF add r8,rax
@tannergooding
tannergooding / HashUtilities.cs
Created June 16, 2017 21:21
Provides a basic C# implementation of the Murmur3 Hash Function
// Licensed under the MIT License (MIT)
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
/// <summary>Provides a set of methods related to computing hashcodes.</summary>
unsafe public static class HashUtilities
{
#region Static Methods
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace System
{
public struct HashCode
{
private int _bytesCombined;
private int _combinedValue;
/* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
started with Java #2 program (Krause/Whipkey/Bennet/AhnTran/Enotus/Stalcup)
adapted for C# by Jan de Vaan
simplified and optimised to use TPL by Anthony Lloyd
simplified to compute Cib alongside Crb by Tanner Gooding
optimized to use Vector<double> by Tanner Gooding
*/
Beginning test case CreateScalar.UInt16 at 1/5/2019 8:30:02 AM
Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro
Beginning scenario: RunBasicScenario
****** START compiling System.Runtime.Intrinsics.Vector128:CreateScalar(ushort):struct (MethodHash=16b94f02)
Generating code for Windows x86
OPTIONS: compCodeOpt = BLENDED_CODE
OPTIONS: compDbgCode = false
OPTIONS: compDbgInfo = true
OPTIONS: compDbgEnC = false
Beginning test case CreateScalar.UInt16 at 1/7/2019 10:14:18 AM
Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro
Beginning scenario: RunBasicScenario
****** START compiling System.Runtime.Intrinsics.Vector128:CreateScalar(ushort):struct (MethodHash=16b94f02)
Generating code for Windows x86
OPTIONS: compCodeOpt = BLENDED_CODE
OPTIONS: compDbgCode = false
OPTIONS: compDbgInfo = true
OPTIONS: compDbgEnC = false
Beginning test case CreateElement.UInt16 at 1/7/2019 10:23:08 AM
Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro
Beginning scenario: RunBasicScenario
****** START compiling System.Runtime.Intrinsics.Vector128:Create(ushort,ushort,ushort,ushort,ushort,ushort,ushort,ushort):struct (MethodHash=1e6cb80c)
Generating code for Windows x86
OPTIONS: compCodeOpt = BLENDED_CODE
OPTIONS: compDbgCode = false
OPTIONS: compDbgInfo = true
OPTIONS: compDbgEnC = false
using System;
using System.Globalization;
public static class DoubleClass
{
public static bool CanBeDouble(string numericStr, out double value)
{
return double.TryParse(numericStr, NumberStyles.Float, CultureInfo.InvariantCulture, out value);
}
}
@tannergooding
tannergooding / Memcpy.cs
Created March 10, 2019 17:30
Simple benchmarks
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
using nuint = System.UInt64;
namespace ConsoleApp3