This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate time; | |
| //use std::io; | |
| //use std::cmp::Ordering; | |
| //use rand::Rng; | |
| use time::{Duration,PreciseTime}; | |
| fn add_array() -> f64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Pricer.PerfTests | |
| open System | |
| open Pricer | |
| open Pricer.Core | |
| open BenchmarkDotNet.Attributes | |
| open BenchmarkDotNet.Running | |
| open BenchmarkDotNet.Configs | |
| open BenchmarkDotNet.Jobs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 _ [] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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|] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |