Algorithm Time Test

Source: Internet
Author: User

1 //algorithm Time Test Datum method (quantitative analysis) Large O method (qualitative analyses)2 //The following is the benchmark method3#include"iostream"4#include"Cstdio"5#include"CTime"6#include"windows.h"7 using namespacestd;8 intMain ()9 {Ten     //fa Yi Oneclock_t Start1,end1;//clock_t Required header file # include "CTime" A     DoubleDuration1; -  -Start1=clock ();//returns the number of milliseconds that the program is running to this location the:: Sleep ( the);//Delay function parameter is milliseconds header file # include "windows.h" note two colons and uppercase S -end1=clock (); -Duration1= (Double) (End1-start1)/clocks_per_sec;//for output seconds, millisecond seconds -cout<<"The clock_t time is"<<duration1<<"S"<<Endl; +  -  +  A     //Method Two at time_t Start2,end2; -  -Start2=time (0);//gets the number of seconds from 1970 1 1 0:0:0 to the present (note Unit is seconds) -:: Sleep ( the); -End2=time (0); -     Doubleduration2=end2-Start2; incout<<"The time_t time is"<<duration2<<"S"<<Endl; -}
View Code

Algorithm Time Test

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.