Skip to content

Instantly share code, notes, and snippets.

View IsAsciiPerf.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Jobs;
using System;
namespace ConsoleApp2
{
[InProcess]
public unsafe class IsAscii
{
private string _earlyCachedA = "1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU";
View IndexOfAny.cpp
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <chrono>
#include <iostream>
#define PROBABILISTICMAP_BLOCK_INDEX_MASK 0X7
#define PROBABILISTICMAP_BLOCK_INDEX_SHIFT 0x3
#define PROBABILISTICMAP_SIZE 0X8
typedef unsigned short WCHAR;
View LoopWithExit.cs
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public unsafe class LoopWithExit
{
public int length = 100;
View EqualsIgnoreCaseAsciiHelper.cs
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public unsafe class CompareOrdinalIgnoreCase
{
[Params(1, 5, 12, 50, 100)]
public int length = 0;
View CompareOrdinalIgnoreCase.cs
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public unsafe class CompareOrdinalIgnoreCase
{
[Params(1, 5, 12, 50, 100)]
public int length = 0;
View StringBuilderPerf.cs
using System;
using System.Diagnostics;
using System.Text;
namespace ConsoleApp2
{
public class Program
{
public static void Main(string[] args)
{
View IndexOfCharMask.cs
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)]
View PadLeftRight.cs
using BenchmarkDotNet.Attributes;
using System;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public class Pad
{
[Params(1, 10, 50, 90, 100)]
public int length = 0;
View ContainsTokenUnroll.cs
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;
View Equals.cs
using BenchmarkDotNet.Attributes;
using System;
using System.Diagnostics;
namespace ConsoleApplication2
{
[Config("jobs=RyuJitX64")]
public unsafe class Equals
{
// Equal