Last active
April 13, 2017 10:30
-
-
Save manofstick/a1891f63a812d000113fabe439b7f08a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "💚" | |
elif ratio < 0.95 then "👍" | |
elif ratio > 1.25 then "💔" | |
elif ratio > 1.05 then "👎" | |
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