Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6150267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:35:31+00:00 2026-05-23T19:35:31+00:00

Hi again with a boost question: I need to calculate the time spent in

  • 0

Hi again with a boost question: I need to calculate the time spent in my function in my boost thread: here is the code:

boost::posix_time::microseconds tes( 12 );
int i = 0;
while( true )
{
    boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time( );

    myFunction( );

    boost::this_thread::sleep( tes );   

    boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time( );

    boost::posix_time::time_duration elapsed = end - start;
}

so I tried many times but the elapsed time_duration is always 0, I’ve added to test the sleep function of 12 microsecs, so in the best ways I will have 12 microsec elapsed but is still 0..
I need to tell to the thread to update the timer after the time read??

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:35:32+00:00Added an answer on May 23, 2026 at 7:35 pm

    According to boost documentation, local_time might not achieve microsecond level resolution on Win32 system:

    ptime microsec_clock::local_time()

    Get the local time using a sub second resolution clock. On Unix systems this is implemented using GetTimeOfDay. On most Win32 platforms it is implemented using ftime. Win32 systems often do not achieve microsecond resolution via this API. If higher resolution is critical to your application test your platform to see the achieved resolution.

    Possibly your only option is using a high resolution timer (not portable)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Again a SED question from me :) So, same as last time, I'm wrestling
I again need help by you, this time I struggle with covariance, contravariance, delegates
I'm using boost::signals2 library and here is the simple code: boost::signals2<void ()> sig; class
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
Once again a question about the garbage collector in actionscript-3: If I have a
I'm aware of this question which mentions Boost's STATIC WARNING, but I'd like to
Maybe my question is quite strange, but it bothers me for some time and
I have an unsigned int storing a random number. I need to use this
Here 'free' means no need to buy any license. As I know VCL comes
Greetings all. I am writing some code using the Boost Units library and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.