Pino Toscano
2015-Jun-03 14:22 UTC
[Libguestfs] [PATCH] mllib: use Unix.gettimeofday instead of Unix.time
Unix.gettimeofday returns a finer resolution than seconds, which is what we need since deciseconds of timestamps are printed. --- mllib/common_utils.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 32e908d..516cff3 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -282,11 +282,11 @@ let verbose () = !verbose (* Timestamped progress messages, used for ordinary messages when not * --quiet. *) -let start_t = Unix.time () +let start_t = Unix.gettimeofday () let message fs let display str if not (quiet ()) then ( - let t = sprintf "%.1f" (Unix.time () -. start_t) in + let t = sprintf "%.1f" (Unix.gettimeofday () -. start_t) in printf "[%6s] " t; ansi_green (); printf "%s" str; -- 2.1.0
Richard W.M. Jones
2015-Jun-03 17:48 UTC
Re: [Libguestfs] [PATCH] mllib: use Unix.gettimeofday instead of Unix.time
On Wed, Jun 03, 2015 at 04:22:07PM +0200, Pino Toscano wrote:> Unix.gettimeofday returns a finer resolution than seconds, which is what > we need since deciseconds of timestamps are printed. > --- > mllib/common_utils.ml | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml > index 32e908d..516cff3 100644 > --- a/mllib/common_utils.ml > +++ b/mllib/common_utils.ml > @@ -282,11 +282,11 @@ let verbose () = !verbose > (* Timestamped progress messages, used for ordinary messages when not > * --quiet. > *) > -let start_t = Unix.time () > +let start_t = Unix.gettimeofday () > let message fs > let display str > if not (quiet ()) then ( > - let t = sprintf "%.1f" (Unix.time () -. start_t) in > + let t = sprintf "%.1f" (Unix.gettimeofday () -. start_t) in > printf "[%6s] " t; > ansi_green (); > printf "%s" str; > -- > 2.1.0Yes indeed ... ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Possibly Parallel Threads
- [PATCH] mllib: use Unix.isatty
- [PATCH 1/3] mllib: add an optional filter for rm_rf_only_files
- Re: [PATCH v4 4/6] mllib: modify nsplit to take optional noempty and count arguments
- [PATCH] mllib: Add isspace, triml, trimr and trim functions.
- [PATCH 1/2] mllib: add normalize_arch helper