Skip to content

Instantly share code, notes, and snippets.

View jackmott's full-sized avatar

Jack Mott jackmott

  • Looking for employment
  • Texas,USA
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / filterUltra.fs
Last active August 19, 2016 21:33
experimental filter
let filterUltra f (array : 'T[]) =
let inline computeChunk (x:float32) =
int((float32)array.Length*x)
let chunkProgression =
match sizeof<'T> * array.Length with
| x when x < 4096 -> [|array.Length|]
| x when x < 65536 -> [|computeChunk 0.25f;computeChunk 0.76f|]
@jackmott
jackmott / bench.fs
Created August 19, 2016 18:35
benmarking template
/// BenchmarkDotNet Notes:
/// Docs/Github: https://github.com/PerfDotNet/BenchmarkDotNet#getting-started
///
/// This benchmarking suite will perform JIT warmups, collect system environment data
/// run multiple trials, and produce convenient reports.
/// You will find csv, markdown, and and html versions of the reports in .\BenchmarkDotNet.Artifacts\results
/// after running the tests.
///
/// Be sure to run tests in Release mode, optimizations on, etc.
@jackmott
jackmott / filter.fs
Last active August 18, 2016 14:03
filter
let filterNew f (array: _[]) =
checkNonNull "array" array
let mutable i = 0
while i < array.Length && not (f array.[i]) do
i <- i + 1
if i <> array.Length then
@jackmott
jackmott / choose.fs
Created August 12, 2016 12:17
Core lib parallel Array.chose F#
let choose f (array: 'T[]) =
let inputLength = array.Length
let isChosen : bool [] = Array.zeroCreate inputLength
let results : 'U [] = Array.zeroCreate inputLength
Parallel.For(0, inputLength, (fun i ->
match f array.[i] with
@jackmott
jackmott / partition.fs
Last active August 11, 2016 03:55
Faster Array.partition for F#
let arrayPartition f (array: _[]) =
checkNonNull array
//Hold both arrays in one of exact length
let res = Array.zeroCreate array.Length
let mutable upCount = 0
let mutable downCount = array.Length-1
for i = 0 to array.Length-1 do
let x = array.[i]
if f x then