Skip to content

Commit

Permalink
[benchmarkdotnet] working
Browse files Browse the repository at this point in the history
  • Loading branch information
haf committed Nov 1, 2016
1 parent 5304084 commit 60a9735
Show file tree
Hide file tree
Showing 6 changed files with 962 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ packages/*
*.sln.ide
project.lock.json
paket-files/
BenchmarkDotNet.Artifacts/
4 changes: 4 additions & 0 deletions Expecto.BenchmarkDotNet/Expecto.BenchmarkDotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ open Expecto.Logging.Message
module BenchmarkDotNet =
let logger = Log.create "Expecto.BenchmarkDotNet"

type BenchmarkAttribute = BenchmarkDotNet.Attributes.BenchmarkAttribute
type CleanupAttribute = BenchmarkDotNet.Attributes.CleanupAttribute
type SetupAttribute = BenchmarkDotNet.Attributes.SetupAttribute

type BenchmarkConfig =
{ columns : IColumn list
exporters : IExporter list
Expand Down
25 changes: 25 additions & 0 deletions Expecto.Tests/BenchmarkDotNet.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Expecto.BenchmarkDotNetTests

open System
open System.Security.Cryptography
open Expecto
open BenchmarkDotNet

type Md5VsSha256() =
[<Literal>]
let N = 10000
let data : byte[] = Array.zeroCreate N
let sha256 = SHA256.Create()
let md5 = MD5.Create()
do Random(42).NextBytes data

[<Benchmark>]
member x.Sha256() = sha256.ComputeHash data
[<Benchmark>]
member x.Md5() = md5.ComputeHash(data)

[<Tests>]
let benchmarks =
testList "some different benchmarks" [
benchmark<Md5VsSha256> "md5 versus sha256" benchmarkConfig ignore
]
Loading

0 comments on commit 60a9735

Please sign in to comment.