Browse Source

Beautified duration message displayed at the end

We are using human readable duration (ms, μs, …) instead of 0.000xxx seconde(s).
Leo 9 years ago
parent
commit
c81e1418b9
2 changed files with 6 additions and 5 deletions
  1. 1 1
      CHANGELOG.md
  2. 5 4
      src/command_def.ml

+ 1 - 1
CHANGELOG.md

@@ -29,7 +29,7 @@
  + Improve list subcommand, now using Textutils library, displaying in an array
  + Improve editing command (explain how to use to add commands, improve
    messages, offer to reedit when nothing was done).
- + Code clean up
+ + Code clean up, messages improvement
  + Add unit tests and clean them up
  + Add licence warning
  + TODO XXX Add basic signal handling (`--signals`), to relaunch when doing

+ 5 - 4
src/command_def.ml

@@ -248,7 +248,7 @@ let default =
 
 let run ~version ~build_info () =
   (* Store begin time *)
-  let start = Time.(now () |> to_float) in
+  let start = Time.now () in
 
 
   (* XXX Hack to allow to run 'oclaunch 5' or 'oclaunch' as before, i.e. do not
@@ -310,9 +310,10 @@ let run ~version ~build_info () =
       | Error -> Messages.warning "Error with lockfile"
   ));
 
-  (* Display total running time, to float is a number of secconds *)
-  Messages.debug Time.(now () |> to_float |> (-.) start |> ( *. ) (-1.)
-  |> sprintf "Runned during %f second(s)");
+  (* Display total running time, pretty printing is handled by Time module *)
+  Messages.debug Time.(diff (now ()) start
+      |> Span.to_string_hum (* Round the value, 3 digits *)
+      |> sprintf "Duration: %s");
 
   (* Reset display *)
   Messages.reset ();