Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Last active August 29, 2015 14:18

Revisions

  1. vasily-kirichenko revised this gist Apr 17, 2015. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion digests.fs
    Original file line number Diff line number Diff line change
    @@ -12,10 +12,14 @@ let bench (input: byte[]) (digest: HashAlgorithm) =
    let input = Array.zeroCreate<byte> 10000000
    [ new MD5CryptoServiceProvider() :> HashAlgorithm
    new SHA1CryptoServiceProvider() :> _

    SHA256.Create() :> _
    new SHA256CryptoServiceProvider() :> _
    new SHA256Cng() :> _

    SHA512.Create() :> _
    new SHA512CryptoServiceProvider() :> _ ]
    new SHA512CryptoServiceProvider() :> _
    new SHA512Cng() :> _ ]
    |> List.iter (bench input)


  2. vasily-kirichenko revised this gist Apr 17, 2015. 1 changed file with 11 additions and 6 deletions.
    17 changes: 11 additions & 6 deletions digests.fs
    Original file line number Diff line number Diff line change
    @@ -2,15 +2,20 @@ open System.Security.Cryptography
    open System.Diagnostics
    open System

    let bench (digest: HashAlgorithm) (input: byte[]) =
    let bench (input: byte[]) (digest: HashAlgorithm) =
    let sw = Stopwatch.StartNew()
    for _ in 1..100 do
    digest.ComputeHash input |> ignore
    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
    bench (MD5.Create()) input
    bench (SHA1.Create()) input
    bench (SHA256.Create()) input
    bench (SHA512.Create()) input
    [ new MD5CryptoServiceProvider() :> HashAlgorithm
    new SHA1CryptoServiceProvider() :> _
    SHA256.Create() :> _
    new SHA256CryptoServiceProvider() :> _
    SHA512.Create() :> _
    new SHA512CryptoServiceProvider() :> _ ]
    |> List.iter (bench input)


  3. vasily-kirichenko revised this gist Apr 11, 2015. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions digests.fs
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@ open System.Diagnostics
    open System

    let bench (digest: HashAlgorithm) (input: byte[]) =
    let sw = Stopwatch.StartNew()
    for _ in 1..100 do
    digest.ComputeHash input |> ignore
    sw.Stop()
    printfn "%s elapled %O" (digest.GetType().Name) sw.Elapsed
    let sw = Stopwatch.StartNew()
    for _ in 1..100 do
    digest.ComputeHash input |> ignore
    sw.Stop()
    printfn "%s elapled %O" (digest.GetType().Name) sw.Elapsed

    let input = Array.zeroCreate<byte> 10000000
    bench (MD5.Create()) input
  4. vasily-kirichenko revised this gist Apr 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion digests.fs
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,4 @@ let input = Array.zeroCreate<byte> 10000000
    bench (MD5.Create()) input
    bench (SHA1.Create()) input
    bench (SHA256.Create()) input
    bench (SHA512.Create()) input
    bench (SHA512.Create()) input
  5. vasily-kirichenko revised this gist Apr 11, 2015. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions digests.fs
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,14 @@ open System.Diagnostics
    open System

    let bench (digest: HashAlgorithm) (input: byte[]) =
    let sw = Stopwatch.StartNew()
    for _ in 1..100 do
    digest.ComputeHash input |> ignore
    sw.Stop()
    printfn "%s elapled %O" (digest.GetType().Name) sw.Elapsed
    let sw = Stopwatch.StartNew()
    for _ in 1..100 do
    digest.ComputeHash input |> ignore
    sw.Stop()
    printfn "%s elapled %O" (digest.GetType().Name) sw.Elapsed

    let input = Array.zeroCreate<byte> 10000000
    bench (MD5.Create()) input
    bench (SHA1.Create()) input
    bench (SHA256.Create()) input
    bench (SHA256.Create()) input
    bench (SHA512.Create()) input
  6. vasily-kirichenko revised this gist Apr 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion digests.fs
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,4 @@ let bench (digest: HashAlgorithm) (input: byte[]) =
    let input = Array.zeroCreate<byte> 10000000
    bench (MD5.Create()) input
    bench (SHA1.Create()) input
    bench (SHA256Cng.Create()) input
    bench (SHA256.Create()) input
  7. vasily-kirichenko created this gist Apr 11, 2015.
    15 changes: 15 additions & 0 deletions digests.fs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    open System.Security.Cryptography
    open System.Diagnostics
    open System

    let bench (digest: HashAlgorithm) (input: byte[]) =
    let sw = Stopwatch.StartNew()
    for _ in 1..100 do
    digest.ComputeHash input |> ignore
    sw.Stop()
    printfn "%s elapled %O" (digest.GetType().Name) sw.Elapsed

    let input = Array.zeroCreate<byte> 10000000
    bench (MD5.Create()) input
    bench (SHA1.Create()) input
    bench (SHA256Cng.Create()) input