-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: New stat folder for the tools to make stat on dowsing
- Move the previous bench tool ther - Now compare take a list of file to compare
- Loading branch information
Showing
6 changed files
with
156 additions
and
120 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
open Containers | ||
|
||
let ratio x y = | ||
let open Float.Infix in | ||
let r = x /. y in | ||
if r < 0.5 then | ||
PrintBox.sprintf_with_style | ||
{ PrintBox.Style.default with bold = true; bg_color = Some Red } | ||
"%.2f x%.2f" (y /. 1_000_000.) r | ||
else if r < 0.7 then | ||
PrintBox.sprintf_with_style | ||
{ PrintBox.Style.default with bold = true; fg_color = Some Red } | ||
"%.2f x%.2f" (y /. 1_000_000.) r | ||
else if r < 0.99 then | ||
PrintBox.sprintf_with_style | ||
{ PrintBox.Style.default with bold = true; fg_color = Some Yellow } | ||
"%.2f x%.2f" (y /. 1_000_000.) r | ||
else if r < 1.01 then | ||
PrintBox.sprintf_with_style PrintBox.Style.default "%.2f x%.2f" | ||
(y /. 1_000_000.) r | ||
else if r < 1.5 then | ||
PrintBox.sprintf_with_style | ||
{ PrintBox.Style.default with bold = true; fg_color = Some Green } | ||
"%.2f x%.2f" (y /. 1_000_000.) r | ||
else | ||
PrintBox.sprintf_with_style | ||
{ PrintBox.Style.default with bold = true; bg_color = Some Green } | ||
"%.2f x%.2f" (y /. 1_000_000.) r | ||
|
||
let get_name file = | ||
let file = Filename.basename file in | ||
try Filename.chop_extension file with Invalid_argument _ -> file | ||
|
||
let compare results = | ||
let results = | ||
List.map | ||
(fun file -> (get_name file, CCIO.with_in file Marshal.from_channel)) | ||
results | ||
in | ||
let _, base = List.hd results in | ||
let grid = | ||
Array.init | ||
(List.length base + 1) | ||
(fun _ -> Array.make (List.length results + 1) (PrintBox.text "")) | ||
in | ||
List.iteri | ||
(fun i (name, _) -> | ||
grid.(0).(i + 1) <- PrintBox.center_hv @@ PrintBox.text name) | ||
results; | ||
List.iteri | ||
(fun r { Bench.ty; feats; _ } -> | ||
grid.(r + 1).(0) <- PrintBox.asprintf "%a" Type.pp ty; | ||
List.iteri | ||
(fun c (_, result) -> | ||
match List.find_opt (fun e -> Type.equal e.Bench.ty ty) result with | ||
| None -> grid.(r + 1).(c + 1) <- PrintBox.text "NA" | ||
| Some res -> | ||
grid.(r + 1).(c + 1) <- ratio feats.time res.Bench.feats.time) | ||
results) | ||
(snd base); | ||
let grid = PrintBox.grid grid in | ||
Format.printf "@[%a@]@." (PrintBox_text.pp_with ~style:true) grid | ||
|
||
open Cmdliner | ||
|
||
let data = | ||
let docv = "DATAS" in | ||
Arg.(value & pos_all file [] & info [] ~docv) | ||
|
||
let compare = | ||
let doc = | ||
"Compare the curent state with a previous state. The databased used must \ | ||
be the same for the test to be relevant." | ||
in | ||
let info = Cmd.info "compare" ~doc in | ||
Cmd.v info Term.(const compare $ data) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(executable | ||
(name main) | ||
(libraries common acic db bechamel bechamel-notty notty.unix cmdliner printbox printbox-text) | ||
(flags | ||
(:standard -open Common -open Utils))) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
open Cmdliner | ||
|
||
let cmds = [ Bench.stat; Compare.compare ] | ||
|
||
let main_cmd, main_info = | ||
let doc = "Benchmark utils for Dowsing" in | ||
( Term.(ret (const (`Error (true, "no command")))), | ||
Cmd.info "bench" ~sdocs:Manpage.s_common_options ~doc ) | ||
|
||
let () = | ||
Logs.(set_reporter @@ format_reporter ()); | ||
exit @@ Cmd.eval @@ Cmd.group ~default:main_cmd main_info cmds |