Simple Application of boost library-processing of time and date (2)

Source: Internet
Author: User

In the previous article, we learned a boost class for processing time. Today we will learn another class for processing time-progress_timer, which inherits from the Timer class, with the Timer class function, we can further improve its ease of use. Next we will describe the class with the code:

# Include <iostream> # include <boost/progress. HPP> int main () {boost: progress_timer pt1; STD: cout <pt1.elapsed _ max () <STD: Endl; STD :: cout <pt1.elapsed _ min () <STD: Endl; STD: cout <pt1.elapsed () <STD: Endl; {boost: progress_timer pt2 ;} return 0 ;}

Since it inherits from timer, various public methods of timer can also be used. When reading the code, you may have questions about the actual purpose of defining an instance pt2 at the end of the Code but not performing any operations on it? The answer is: yes, because progress_timer automatically starts timing during the construction, and outputs the result to the stream during the analysis, which is output by the output stream. Therefore, it is more convenient than timer, so we do not need to perform any operations, and everything is executed by itself. This block scope declaration method in the Code is also useful for testing multiple algorithms in the same code.

Finally, we need to note that the accuracy of progress_timer is not less than two digits after the decimal point. If you need more precision, You need to customize it.

Simple Application of boost library-processing of time and date (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.