Skip to content

Instantly share code, notes, and snippets.

@dawedawe
Last active January 14, 2024 20:25
Show Gist options
  • Save dawedawe/c41214a0d36cdbee44077da2ea6277fd to your computer and use it in GitHub Desktop.
Save dawedawe/c41214a0d36cdbee44077da2ea6277fd to your computer and use it in GitHub Desktop.
QuickAndDirtyTcBenchmark
#r "nuget: CliWrap"
open System.Threading
open CliWrap
let baselineFscPath =
@"C:\Users\schae\src\fsharp_main\artifacts\bin\fsc\Release\net8.0\fsc.dll"
let hypothesisFscPath =
@"C:\Users\schae\src\fsharp\artifacts\bin\fsc\Release\net8.0\fsc.dll"
let runs = 10
let createTimes fscPath csvName =
for i in 1..runs do
printfn $"run {i}"
let cmd =
Cli
.Wrap("dotnet")
.WithArguments(
[ "build"
$"/p:OtherFlags=\"DotnetFscCompilerPath='{fscPath}'\""
$"/p:OtherFlags=\"--times:{csvName}{i}.csv\""
"-c"
"Release"
"--no-incremental" ]
)
cmd.ExecuteAsync(CancellationToken.None).Task
|> Async.AwaitTask
|> Async.RunSynchronously
|> ignore
let calcAvgTime (paths: string array) =
[| for path in paths do
let lines = System.IO.File.ReadAllLines(path)
let typecheckLine = lines[13]
let values = typecheckLine.Split(',')
let value = values[3]
printfn "%s" value
yield double (value) |]
|> Array.average
let createBaseline () =
createTimes baselineFscPath "baseline"
let paths =
[| for i in 1..runs do
yield $"baseline{i}.csv" |]
let avg = calcAvgTime paths
printfn "baselineAvg = %f" avg
let createHypothesis () =
createTimes hypothesisFscPath "hypothesis"
let paths =
[| for i in 1..runs do
yield $"hypothesis{i}.csv" |]
let avg = calcAvgTime paths
printfn "hypothesisAvg = %f" avg
createBaseline ()
createHypothesis ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment