Skip to content

Instantly share code, notes, and snippets.

View jackmott's full-sized avatar

Jack Mott jackmott

  • Olo
  • Texas,USA
View GitHub Profile
@jackmott
jackmott / bench.cs
Created August 23, 2016 12:59
C# benchmarks
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Diagnostics.Windows;
namespace bigo
@jackmott
jackmott / sort.hs
Created August 23, 2016 20:38
mergesort
mergesort :: (a -> a -> Ordering) -> [a] -> [a]
mergesort cmp = mergesort' cmp . map wrap
mergesort' :: (a -> a -> Ordering) -> [[a]] -> [a]
mergesort' _ [] = []
mergesort' _ [xs] = xs
mergesort' cmp xss = mergesort' cmp (merge_pairs cmp xss)
merge_pairs :: (a -> a -> Ordering) -> [[a]] -> [[a]]
merge_pairs _ [] = []
@jackmott
jackmott / benchsample.cs
Last active August 24, 2016 09:09
sample benchmark
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Diagnostics.Windows;
namespace bigo
@jackmott
jackmott / perftest.fs
Created August 24, 2016 15:32
Pricer Perf Test
module Pricer.PerfTests
open System
open Pricer
open Pricer.Core
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open BenchmarkDotNet.Configs
open BenchmarkDotNet.Jobs
@jackmott
jackmott / rusttest.rs
Created August 25, 2016 20:11
rusttest
extern crate time;
//use std::io;
//use std::cmp::Ordering;
//use rand::Rng;
use time::{Duration,PreciseTime};
fn add_array() -> f64
@jackmott
jackmott / gotest.go
Last active August 28, 2016 12:25
go test
package main
import "fmt"
import "time"
func main() {
var values [32000000]float64
for i := 0; i < len(values); i++ {
values[i] = 2.0
}
@jackmott
jackmott / linq.md
Created August 31, 2016 01:13
LinqTests
Host Process Environment Information:
BenchmarkDotNet.Core=v0.9.9.0
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4712HQ CPU 2.30GHz, ProcessorCount=8
Frequency=2240905 ticks, Resolution=446.2483 ns, Timer=TSC
CLR=MS.NET 4.0.30319.42000, Arch=64-bit RELEASE [RyuJIT]
GC=Concurrent Workstation
JitModules=clrjit-v4.6.1590.0
@jackmott
jackmott / linqtest.cs
Created August 31, 2016 01:15
LinqTestSource
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Diagnostics.Windows;
namespace bigo
@jackmott
jackmott / maptest.md
Last active August 31, 2016 02:58
maptest fsharp

Simple mapping function (fun x -> x*x) 1,000,000 ints

      Method |  Length |    Median |    StdDev | Scaled | Gen 0 | Gen 1 |  Gen 2 | Bytes Allocated/Op |

---------------- |-------- |---------- |---------- |------- |------ |------ |------- |------------------- | Parallelmap | 1000000 | 3.7892 ms | 0.4924 ms | 1.85 | - | - | 880.58 | 1,749,410.73 | map | 1000000 | 2.0427 ms | 0.0211 ms | 1.00 | - | - | 793.00 | 1,755,648.30 | SIMDmap | 1000000 | 1.7126 ms | 0.0175 ms | 0.84 | - | - | 777.53 | 1,721,123.56 | SIMDParallelmap | 1000000 | 1.6008 ms | 0.0267 ms | 0.78 | - | - | 926.58 | 1,590,658.22 |

More complex mapping function(fun x->x*(x*x+x+x/5.0f)) 1,000,000 float32s

@jackmott
jackmott / JBlowFsharp.fs
Last active September 1, 2016 20:32
Example of poly_inc map combo in Fsharp
let inline map (array : 'T[]) f : 'U[] =
let result = Array.zeroCreate array.Length
for i = 0 to array.Length-1 do
result.[i] <- f array.[i]
result
let inline poly_incr x =
x + LanguagePrimitives.GenericOne
[<EntryPoint>]