Last active
August 29, 2015 14:18
This file contains 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.Security.Cryptography | |
open System.Diagnostics | |
open System | |
let bench (input: byte[]) (digest: HashAlgorithm) = | |
let sw = Stopwatch.StartNew() | |
for _ in 1..100 do | |
digest.ComputeHash input |> ignore // |> M.toHex |> printfn "%s" | |
sw.Stop() | |
printfn "%s elapled %O" (digest.GetType().Name) sw.Elapsed | |
let input = Array.zeroCreate<byte> 10000000 | |
[ new MD5CryptoServiceProvider() :> HashAlgorithm | |
new SHA1CryptoServiceProvider() :> _ | |
SHA256.Create() :> _ | |
new SHA256CryptoServiceProvider() :> _ | |
new SHA256Cng() :> _ | |
SHA512.Create() :> _ | |
new SHA512CryptoServiceProvider() :> _ | |
new SHA512Cng() :> _ ] | |
|> List.iter (bench input) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment