Skip to content

Instantly share code, notes, and snippets.

@mburbea
mburbea / Create_funcs.sql
Last active August 29, 2015 14:01
SplitTest v3
/* This script is just the creation of the objects. Useful if you just want to add the functions
* to an existing database.
* You don't need to take all of them.
* Hybrid is depedent on HybridInternal
* HybridNV depends on HybridNVInternal
* SplitVarchar,SplitVarcharA depend on SplitVarbinary
* SplitNVarchar depends on SplitNVarcharInternal
* the baseline functions are for diagnostic purposes only. They are not splitters!
* They return 1 less then their third parameter number of chunks of the first parameter.
*/
@mburbea
mburbea / ByteIndexOf.cs
Last active August 29, 2015 14:02
Playing with SIMD
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Collections;
@mburbea
mburbea / FlagEnumConverter.cs
Last active September 4, 2017 18:07
FlagEnumConverter
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Concurrent;
using System.Globalization;
using System.Runtime.Serialization;
namespace Extensions
{
@mburbea
mburbea / SpecifiedConverterContractResolver.cs
Created December 10, 2014 22:23
SpecifiedConverterContractResolver
public class SpecifiedConverterContractResolver : DefaultContractResolver
{
readonly List<JsonConverter> _converters;
readonly bool _camelCaseProperties;
public SpecifiedConverterContractResolver(bool camelCaseProperties, IEnumerable<JsonConverter> converters)
{
if (converters == null)
{
throw new ArgumentNullException("converters");
@mburbea
mburbea / program.cs
Created January 22, 2015 16:36
StructEnumerator
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace ConsoleApplication1
{
@mburbea
mburbea / program.cs
Created February 4, 2015 06:26
ArrayByteIndexIsSlow
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
namespace ConsoleApplication1
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
namespace ConsoleApplication2
{
public static class CachingIEnumerable
{
@mburbea
mburbea / CreateSplit.sql
Last active April 13, 2016 18:05
Hybrid Split 2015
if object_id('dbo.fn_split') is not null drop function fn_split;
if object_id('dbo.splitVarbinary') is not null drop function dbo.splitvarbinary;
if exists (select 1 from sys.assemblies where name='split') drop assembly split;
CREATE ASSEMBLY [Split]
AUTHORIZATION [dbo]
FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300673BF4560000000000000000E00002210B010B00000C00000006000000000000AE2B0000002000000040000000000010002000000002000004000000000000000600000000000000008000000002000000000000030060850000100000100000000010000010000000000000100000000000000000000000582B00005300000000400000A002000000000000000000000000000000000000006000000C000000202A00001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000
@mburbea
mburbea / string_split_perf_into_table_is_poor.sql
Created April 13, 2016 18:25
Sql 2016's string_split function screams when you don't need to save the elements into a table. If you do need to do that, then it's slow! Almost as slow as an optimized t-sql split func.
if object_id('dbo.fn_split') is not null drop function fn_split;
if object_id('dbo.splitVarbinary') is not null drop function dbo.splitvarbinary;
if exists (select 1 from sys.assemblies where name='split') drop assembly split;
CREATE ASSEMBLY [Split]
AUTHORIZATION [dbo]
FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300673BF4560000000000000000E00002210B010B00000C00000006000000000000AE2B0000002000000040000000000010002000000002000004000000000000000600000000000000008000000002000000000000030060850000100000100000000010000010000000000000100000000000000000000000582B00005300000000400000A002000000000000000000000000000000000000006000000C000000202A00001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000
@mburbea
mburbea / DeBruijnBenchmark.cs
Last active October 6, 2016 16:56
Redux test
using BenchmarkDotNet.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BenchmarkDotNet.Configs;