Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vasily-kirichenko/b376de7968f80c0faab6 to your computer and use it in GitHub Desktop.
Save vasily-kirichenko/b376de7968f80c0faab6 to your computer and use it in GitHub Desktop.
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