Skip to content

Commit

Permalink
adding benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
jan fajfr committed Nov 22, 2016
1 parent 80811af commit 71da62e
Show file tree
Hide file tree
Showing 19 changed files with 853 additions and 1,180 deletions.
6 changes: 6 additions & 0 deletions Pricer.Benchmark/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
41 changes: 41 additions & 0 deletions Pricer.Benchmark/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace Pricer.Benchmark.AssemblyInfo

open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("Pricer.Benchmark")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("Pricer.Benchmark")>]
[<assembly: AssemblyCopyright("Copyright © 2016")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("b6f00746-8eb4-4e05-8d87-d5e423bf9fe7")>]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]

do
()
22 changes: 22 additions & 0 deletions Pricer.Benchmark/Benchmarking.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#r "bin/Debug/Pricer.Core.dll"
#r "bin/Debug/Pricer.dll"
#r "bin/Debug/Pricer.Benchmark.exe"

#r "../packages/BenchmarkDotNet/lib/net45/BenchmarkDotNet.dll"
#r "../packages/BenchmarkDotNet.Core/lib/net45/BenchmarkDotNet.Core.dll"
#r "../packages/BenchmarkDotNet.Toolchains.Roslyn/lib/net45/BenchmarkDotNet.Toolchains.Roslyn.dll"
#r "../packages/BenchmarkDotNet.Diagnostics.Windows/lib/net45/BenchmarkDotNet.Diagnostics.Windows.dll"
#r "../packages/Microsoft.CodeAnalysis.CSharp/lib/net45/Microsoft.CodeAnalysis.CSharp.dll"
#r "../packages/Microsoft.CodeAnalysis.Common/lib/net45/Microsoft.CodeAnalysis.dll"
#r "../packages/System.Reflection.Metadata/lib/netstandard1.1/System.Reflection.Metadata.dll"
#r "../packages/System.Collections.Immutable/lib/netstandard1.0/System.Collections.Immutable.dll"
#r "../packages/System.Threading.Tasks.Extensions/lib/netstandard1.0/System.Threading.Tasks.Extensions.dll"


open Pricer.Core
open Pricer
open Pricer.Benchmark
open BenchmarkDotNet.Running

let summary = BenchmarkRunner.Run<BinomialBenchmark>();
printfn "%A" summary
94 changes: 43 additions & 51 deletions Pricer.Tests/PerfTests.fs → Pricer.Benchmark/BinomialBenchmark.fs
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
namespace Pricer.Tests

open System
open Pricer
open Pricer.Core
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open BenchmarkDotNet.Configs
open BenchmarkDotNet.Jobs

#if MONO
#else
open BenchmarkDotNet.Diagnostics.Windows
#endif

type BenchConfig () =
inherit ManualConfig()
do
base.Add Job.RyuJitX64
#if MONO
#else
base.Add(new MemoryDiagnoser())
#endif

[<Config (typeof<BenchConfig>)>]
type BinomialBenchmark () =

let stock = {
Volatility = 0.05
Rate = 0.03
CurrentPrice = 230.0
}

let europeanCall = {
Strike = 231.0
Expiry = new DateTime(2015,12,12)
Direction = 1.0
Kind = Call
Style = European
PurchaseDate = new DateTime(2015,9,5)
}

[<Params (1000)>]
member val public Steps = 0 with get, set

[<Setup>]
member self.SetupData () =
()

[<Benchmark>]
member self.Func () =
namespace Pricer.Benchmark

open System
open Pricer
open Pricer.Core
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open BenchmarkDotNet.Configs
open BenchmarkDotNet.Jobs
open BenchmarkDotNet.Diagnostics.Windows

type BenchConfig () =
inherit ManualConfig()
do
base.Add Job.RyuJitX64
#if MONO
#else
base.Add(new MemoryDiagnoser())
#endif

[<Config (typeof<BenchConfig>)>]
type BinomialBenchmark () =

let stock = {
Volatility = 0.05
Rate = 0.03
CurrentPrice = 230.0
}

let europeanCall = {
Strike = 231.0
Expiry = new DateTime(2015,12,12)
Direction = 1.0
Kind = Call
Style = European
PurchaseDate = new DateTime(2015,9,5)
}

[<Params (1000, 2000, 3000)>]
member val public Steps = 0 with get, set

[<Benchmark>]
member self.Binomial () =
Binomial.binomial stock europeanCall self.Steps Functional
Loading

0 comments on commit 71da62e

Please sign in to comment.