Skip to content

Instantly share code, notes, and snippets.

View bbarry's full-sized avatar

Bill Barry bbarry

  • Ren Inc
  • Pennsylvania
View GitHub Profile
using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ConsoleApp2 {
public class Benchmarking {
private static int[] gArray;
private static List<int> gList;
[Fact(Skip = "This test generator is capable of producing crashes that are not yet fixed; see, for example, Fuzz5815")]
public void Fuzz()
{
int dt = Math.Abs(new DateTime().Ticks.GetHashCode() % 10000000);
// generate a pattern-matching switch randomly from templates
string[] expressions = new[]
{
"M", // a method group
@bbarry
bbarry / _1_source.cs
Last active November 23, 2016 19:25
async inlined
using System;
using System.Threading.Tasks;
public class C {
static async Task A()
{
var a = 0;
await B();
Console.Write(a++);
await B();
@bbarry
bbarry / Program.cs
Last active September 11, 2016 18:48
testing program for verifying linear algorithm compared to quadratic algorithm for roslyn issue 13685: https://github.com/dotnet/roslyn/issues/13685
using System;
using System.Collections.Generic;
using System.Linq;
using Combinatorics.Collections;
namespace ConsoleApp1
{
public class Program
{
public static void Main(string[] args)
/// <summary>
/// A skip list is an ordered collection with O(log(n)) average case searching, inserting and removal. It also provides
/// O(n) enumeration and constant time access to the first element.
/// While the standard implementation is nondeterministic and based on overlapping forward linked lists, this
/// implementation is deterministic and uses double linked lists to provide constant time acess to the last element and
/// O(n) enumeration in reverse order as well as optimized insertion and removal for items in the last position.
/// </summary>
/// <typeparam name="T"></typeparam>
[PublicAPI]
[DebuggerDisplay("Count = {Count}, First = {SafeFirst}, Last = {SafeLast}")]
@bbarry
bbarry / ChangeMaker.cs
Created June 15, 2016 22:20
change making algorithm
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
namespace ConsoleApplication1
{
public class Program
@bbarry
bbarry / Knapsack.cs
Created June 14, 2016 14:50
various knapsack implementations
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
namespace ConsoleApplication1
{
public class Program
{
var tracer = new Array2DTracer();
var logger = new LogTracer();
var D = [
Array1D.random(20, 0, 50),
Array1D.random(20, 0, 0)
];
tracer._setData(D);
@bbarry
bbarry / realworld.csproj
Created May 11, 2016 22:02
masked csproj file of an actual project in one of my solutions dll projects
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>1.0.12345</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>