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
open System | |
open System.IO | |
open System.Runtime.Serialization.Formatters.Binary | |
let filename = @"E:\binary"; | |
let data = [ | |
"This", 1 | |
"is", 2 | |
"just", 3 |
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
open System.Collections.Generic | |
let validate = false | |
#if FROM_MAX | |
let lowerBound = System.Int32.MaxValue - 100000000 | |
let upperBound = System.Int32.MaxValue | |
#else | |
#if FROM_MIN | |
let lowerBound = System.Int32.MinValue |
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
@@ -65,7 +65,8 @@ type UnionReprDecisions<'Union,'Alt,'Type> | |
isStruct:'Union->bool, | |
nameOfAlt : 'Alt -> string, | |
makeRootType: 'Union -> 'Type, | |
makeNestedType: 'Union * string -> 'Type) = | |
makeNestedType: 'Union * string -> 'Type, | |
hasHelpers: 'Union->IlxUnionHasHelpers) = | |
static let TaggingThresholdFixedConstant = 4 |
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 cli = new System.Net.WebClient () | |
let data = | |
cli.DownloadString "https://raw.githubusercontent.com/dwyl/english-words/master/words.txt" | |
|> fun s -> s.Split ([|"\n"; "\r"; System.Environment.NewLine|], System.StringSplitOptions.None) | |
printfn "found %d words - shuffling" data.Length | |
let r = System.Random () | |
for i = 0 to data.Length-1 do | |
let j = r.Next (i, data.Length-1) |
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 BitCountingAlgorithms = | |
let inline fastGetBitsCount (i:uint32) = | |
let mutable i = i - ((i >>> 1) &&& 0x55555555u) | |
i <- (i &&& 0x33333333u) + ((i >>> 2) &&& 0x33333333u) | |
(((i + (i >>> 4)) &&& 0x0F0F0F0Fu) * 0x01010101u) >>> 24 | |
let safeGetBits (i:uint32) = | |
let mutable count = 0u | |
let mutable n = i | |
while n <> 0u do |
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 boolToUInt32 (b:bool) = (# "conv.u4" (# "cgt.un" b 0 : int32 #) : uint32 #) | |
module internal Filter = | |
[<Struct; NoComparison; NoEquality>] | |
type MaskStruct = | |
val mutable _0x00 : bool | |
val mutable _0x01 : bool | |
val mutable _0x02 : bool | |
val mutable _0x03 : bool |
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 NotFastInBenchmarkDotNet | |
open System.Runtime.InteropServices | |
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
// NOTE THAT THIS IS NOT PARTICULARLY PORTABLE, AS I'M RELYING ON PARTICULAR ENDIANNESS | |
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
[<Struct; StructLayout (LayoutKind.Explicit); NoComparison; NoEquality>] | |
type private BoolToUint32 = |
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
module SomeNamespace.String | |
open System | |
open System.Globalization | |
let inline private safe s = | |
match s with | |
| null -> String.Empty | |
| _ -> s |
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
open FSharp.Quotations | |
let rec getMethodInfo = function | |
| Patterns.Call(_,``method``,_) -> ``method`` | |
| Patterns.Lambda(_,body) -> getMethodInfo body | |
| _ -> failwith "Unexpected Form" | |
let getGenericMethodInfo functionExpression = | |
let methodInfo = getMethodInfo functionExpression | |
if methodInfo.IsGenericMethod then |