Boost logo

Boost Users :

From: __PPS__ (i-love-spam_at_[hidden])
Date: 2005-11-21 01:39:46


Will Bryant wrote:
> __PPS__ wrote:
>
>>any ideas what's wrong, why clock() doesn't work anymore?
>
> I'd hazard a guess that that's because it's measuring process CPU time
> rather than wall clock time. If you replace the thing you're timing
> with some solid computation, does clock() suddenly start giving the
> results you expect?
>

If I understand right, what you say is that these delays are due to
interaction with the os and they are not counted by clock (for this
process)?
I didn't think about it, neither I found any info about that.
My example uses sqlite to insert thousands of rows of data. (disk or
ramfs access)

i'm writing a simple test example...
... ok, I verified, that timings are correct when ther's no interraction
with the os:

#include <iostream>
#include <ctime>
#include <boost/progress.hpp>

using namespace std;
using namespace boost;

int main(){
   clock_t c(clock());
   time_t t(time(0));
   progress_timer pt;
   for(int i=1, z; i; ++i){
     z+=i;
   }
   std::cout << "elapsed time is: " <<
     ((double(clock())-c)/CLOCKS_PER_SEC) <<
     "s (" << (time(0)-t) << ")\n";
}

"test_clock.cpp" 18 lines, 343 characters
%g++34 test_clock.cpp -o main
%./main
elapsed time is: 52.1641s (53)
52.16 s

So, my measurements (from the original post) show time taken by my
routine to execute, minus everything that's done by the OS?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net