Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
namespace ConsoleApplication2
{
using System.Diagnostics;
using Xunit.Abstractions;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
// Remove "static" from "public static unsafe class StringTests"
[Fact]
public void TestStartsWithPerfMatch1Char()
{
@bbowyersmyth
bbowyersmyth / StartsWithAlignedUnaligned.cs
Last active January 25, 2016 22:38
StartsWithAlignedUnaligned
using BenchmarkDotNet;
using BenchmarkDotNet.Tasks;
using System;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace ConsoleApplication2
{
[BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
public class StringCompare
@bbowyersmyth
bbowyersmyth / Replace.cs
Created March 1, 2016 06:32
ReplaceChar
using BenchmarkDotNet;
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public class Replace
{
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public class IndexOf
{
// Not found
[Params(1, 12, 50, 100, 200, 500)]
using BenchmarkDotNet.Attributes;
using System;
using System.Diagnostics;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public unsafe class Equals
{
// Equal
public static bool ContainsTokenUnroll(string value, string token, char delimiter = ';')
{
if (string.IsNullOrEmpty(token)) return false;
if (string.IsNullOrEmpty(value)) return false;
var valueLength = value.Length;
var tokenLength = token.Length;
if (tokenLength > valueLength) return false;
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public class Pad
{
[Params(1, 10, 50, 90, 100)]
public int length = 0;
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public class IndexOf
{
// Not found
//[Params(1, 12, 20, 30, 40, 50, 100, 200, 500)]
using System;
using System.Diagnostics;
using System.Text;
namespace ConsoleApp2
{
public class Program
{
public static void Main(string[] args)
{