c++ - How to use boost to track real time instead of user+sys? -


I am using boost :: timer to make a block of my code I run the code with a thread:

  $ time ./runfoo 1 2.08s real 0m2.086s user 0m1.611s sys 0m0.475s   

The output of 2.08 t.elapsed () is.

However, if I run the code with 4 threads:

  $ time. / Runfoo 4 has gone 2.47s real 0m1.022s user 0m1.834s sys 0m0.628s   

It seems that tracking user + sys time is not real time.

How can I track it in real time? I am using Boost 1.46. To be more specific, the timer is in the main thread, which just calls a function that ends using multiple threads.

Edit: The related source looks like this:

  Promotion :: asio :: io_service ios; Promotion: Thread_Group pool; Boost :: asio :: io_service :: Job work (ios); Pool.create_thread (boost :: bind (and boost :: aso :: io_service :: runs, & ioService)); Pool.create_thread (boost :: bind (and boost :: aso :: io_service :: runs, & ioService)); Pool.create_thread (boost :: bind (and boost :: aso :: io_service :: runs, & ioService)); Pool.create_thread (boost :: bind (and boost :: aso :: io_service :: runs, & ioService)); (Promotion: Timer T; function_which_posts_to_ios (IOS); Printf (""% .2fs taken \ n ", t.elapsed ();}   

I hope the form of which output In order to print the program, I should look at the second run instead of "code 1.02s" to "taken 2.47s" as 1.02s The actual amount of seconds passed was in the form.

It appears that you elapsed ) were not consistent in platforms, others And some CPU time-time clock time. In this, has passed () method gives a structure that is genuine, user and specific member for system time.

If you can not use version 2 API, you can use boost :: posix_time instead of measuring the time of the clock. < / Html>

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -