Version franaise
Home About Download Resources Contact us
Browse thread
Execution time of class versus record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Quc_Peyrot <chojin@l...>
Subject: Re: [Caml-list] Re: Execution time of class versus record

On Jun 26, 2007, at 3:35 PM, Sam Steingold wrote:

>> Please, knows someone what I'm doing wrong?
>>  let t0 = Unix.gettimeofday () in
>>  Printf.printf "elapsed = %f\n" (Unix.gettimeofday() -. t0)
>
> Unix.gettimeofday is "wall clock".
> Unix.times is "CPU time".
> use the latter to time your programs because the former depends on the
> machine load at the time of the test while the latter does not.

In my experience, you need both.

Thread locks, NFS latency, load and so on can indeed impact the wall  
clock
but it is ultimately what the customers are seeing. If you don't  
measure it,
you might be missing bugs or possible IO optimizations. Some code might
be looking perfectly fine in CPU time, but be catastrophic in real  
wall clock
due to various reasons.

But you also need the CPU Time to make sense of the wall clock time.
Once a slow part of the code is identified (using wall clock) and once
load or IO problems have been ruled out, it's good to use the CPU
time to measure any optimizations done.

What I meant is:
- most of the time, if the machine is not really overloaded CPU Time  
~= wall clock
   In this case, it's good to only look at the CPU Time
- If you see that overall, on all the measures in all parts of the  
program there is
   a huge difference between CPU and wall clock, then it is probably  
a general
   load problem
- But, you might see a huge difference only in certain part of the  
program,
   in such cases, it should be investigated.

If you only measure wall clock, or CPU Time, you might just miss some  
part
of the big picture.

My 2 cents

-- 
Best Regards,
Quc