Skip to content

Instantly share code, notes, and snippets.

@manofstick
Last active April 13, 2017 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manofstick/a1891f63a812d000113fabe439b7f08a to your computer and use it in GitHub Desktop.
Save manofstick/a1891f63a812d000113fabe439b7f08a to your computer and use it in GitHub Desktop.
open System
open System.IO
type Test = {
Core : string
Bittage : string
Name : string
Time : float
}
[<EntryPoint>]
let main argv =
let lines = File.ReadAllLines @"c:\tmp\20170413.csv"
let tests =
lines
|> Seq.map (fun line -> line.Split ',')
|> Seq.map (fun parts -> { Core = parts.[0]; Bittage = parts.[1]; Name = parts.[2]; Time = Double.Parse parts.[3] })
let results =
tests
|> Seq.groupBy (fun t -> t.Core, t.Bittage, t.Name)
|> Seq.map (fun ((core, bittage, name), data) ->
let time =
data
|> Seq.map (fun t -> t.Time)
|> Seq.sort
|> Seq.skip 1
|> Seq.sortDescending
|> Seq.skip 1
|> Seq.average
{ Core = core;
Bittage = bittage;
Name = name;
Time = time })
let notes =
[
"TheBurningMonk - Euler - 005", "https://github.com/Microsoft/visualfsharp/pull/2745#issuecomment-290972486"
] |> Map.ofList
let mutable lastName = String.Empty
for bittage, dataByBittage in results |> Seq.groupBy (fun x -> x.Bittage) do
printfn @"
Test | Bittage | Old time (ms) | New time (ms) | New / Old | Summary
------------ | ------------- | ------------- | ------------- | ------------- | -------------"
for name, dataByName in dataByBittage |> Seq.groupBy (fun x -> x.Name) do
let core =
dataByName
|> Seq.groupBy (fun x -> x.Core)
|> Seq.map (fun (core, test) -> core, (test |> Seq.exactlyOne |> fun t -> t.Time))
|> dict
if core.Count <> 2 then failwith "unexpected data"
let useName =
if lastName = name then "..."
else
match notes |> Map.tryFind name with
| None -> name
| Some note -> sprintf "[%s](%s)" name note
lastName <- name
let ratio = core.["New"] / core.["Old"]
let summary =
if ratio < 0.5 then "&#x1F49A;"
elif ratio < 0.95 then "&#x1F44D;"
elif ratio > 1.25 then "&#x1F494;"
elif ratio > 1.05 then "&#x1F44E;"
else ""
printfn "%s | %s | %.1f | %.1f | %.2f | %s" useName bittage core.["Old"] core.["New"] ratio summary
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment