Skip to content

Commit

Permalink
bench: use html tables when available (coq/coq#17559) (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross authored May 4, 2023
2 parents 5014cda + 5ee11fc commit a660554
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/actions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,29 @@ let fetch_bench_results ~job_info () =
>>= fun () -> Lwt.return ""
in
let* slow_table =
let* slow_table_or_err = artifact_url "slow_table.html" |> fetch_artifact in
match slow_table_or_err with
| Ok s ->
Lwt.return s
| Error _ ->
let* slow_table_or_err = artifact_url "slow_table" |> fetch_artifact in
match slow_table_or_err with
| Ok s ->
Lwt.return s
Lwt.return (code_wrap s)
| Error err ->
Lwt_io.printlf "Error fetching slow_table: %s" err
>>= fun () -> Lwt.return ""
in
let* fast_table =
let* fast_table_or_err = artifact_url "fast_table" |> fetch_artifact in
let* fast_table_or_err = artifact_url "fast_table.html" |> fetch_artifact in
match fast_table_or_err with
| Ok s ->
Lwt.return s
| Error _ ->
let* fast_table_or_err = artifact_url "fast_table" |> fetch_artifact in
match fast_table_or_err with
| Ok s ->
Lwt.return (code_wrap s)
| Error err ->
Lwt_io.printlf "Error fetching fast_table: %s" err
>>= fun () -> Lwt.return ""
Expand Down Expand Up @@ -364,16 +374,15 @@ let bench_text = function
| Ok results ->
(* Formatting helpers *)
let header2 str = f "## %s" str in
let code_wrap str = f "```\n%s\n```" str in
(* Document *)
let open BenchResults in
[ header2 ":checkered_flag: Bench Summary:"
; code_wrap results.summary_table
; results.failures
; header2 @@ f ":turtle: Top %d slow downs:" results.slow_number
; code_wrap results.slow_table
; results.slow_table
; header2 @@ f ":rabbit2: Top %d speed ups:" results.fast_number
; code_wrap results.fast_table ]
; results.fast_table ]
|> String.concat ~sep:"\n" |> Lwt.return
| Error e ->
f "Error occured when creating bench summary: %s\n" e |> Lwt.return
Expand All @@ -390,15 +399,14 @@ let bench_comment ~bot_info ~owner ~repo ~number ~gitlab_url ?check_url
f "<details>\n<summary>%s</summary>\n\n%s\n\n</details>\n" summary
text
in
let code_wrap str = f "```\n%s\n```" str in
let link text url = f "[%s](%s)" text url in
[ ":checkered_flag: Bench results:"
; code_wrap results.summary_table
; results.failures
; details (f ":turtle: Top %d slow downs" results.slow_number)
@@ code_wrap results.slow_table
results.slow_table
; details (f ":rabbit2: Top %d speed ups" results.fast_number)
@@ code_wrap results.fast_table
results.fast_table
; "- " ^ link ":chair: GitLab Bench Job" gitlab_url ]
@ Option.value_map
~f:(fun x -> ["- " ^ link ":spiral_notepad: Bench Check Summary" x])
Expand Down
2 changes: 2 additions & 0 deletions src/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open Base

let f = Printf.sprintf

let code_wrap str = f "```\n%s\n```" str

let string_match ~regexp ?(pos = 0) string =
try
let (_ : int) = Str.search_forward (Str.regexp regexp) string pos in
Expand Down
3 changes: 3 additions & 0 deletions src/helpers.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
val f : ('a, unit, string) format -> 'a

val code_wrap : string -> string
(** [code_wrap] = [f "```\n%s\n```"] *)

val string_match : regexp:string -> ?pos:int -> string -> bool

val fold_string_matches :
Expand Down

0 comments on commit a660554

Please sign in to comment.