OK. First time back on here in a few years. Long story short, I need some assistance trying to wrap my head around the clock_gettime() function.
Also, this is for a college coarse assignment. Please DO NOT post anything that could POSSIBLY break the AMC code of ethics, in regards to all of its guidelines.
The assignment in question is this:
The user inputs a number tat is to be searched for in a sorted vector. We are to time the std:find and std::lower_bound searching algorithms that we are required to utilize. The issue that I am having with this is not this part but rather how to use the clock_gettime() function calls.
Any and all help with this issue will be and is GREATLY appriciated.
I need a clean, clear-cut explanation of each method that needs to be used to time a specific block of code. (ex. std::binary_search, std::find, etc...) Now, don't misunderstand what I want. What I DON'T want is to be told HOW to implement my code but rather what each method does and WHY. I will give a format and hopefully it will make responding to this so easy that it won't take more than 10 minutes of your time. This is the webpage that I am using to "try" to understand how to implement the clock_gettime() function call. Call me crazy but I think that its made very poorly and is in dire need of an overhaul to the presentation of the information. (Disclaimer: Personal Opinion...)
URL:
http://linux.die.net/man/3/clock_gettime
Lets begin:
=========================================================
=========================================================
CLOCK_PROCESS_CPUTIME_ID:
-------------------------
What is the "type" for this constant?
-------------------------------------
(And yes, I'm being serious. The error I'm getting is telling me it require a type def or something along those lines...)
Answer: //your answer goes here...
How is it supposed to be GENERICALLY implemented?
-------------------------------------------------
//Example goes here...
=============================================================================
=============================================================================
Timespec Object (as defined in <ctime> (if it even is...):
----------------------------------------------------------
How do I construct one?
-----------------------
Answer: //your answer goes here...
How is it supposed to be GENERICALLY implemented?
-------------------------------------------------
//Example goes here...
=============================================================================
=============================================================================
clock_gettime():
----------------
I am under the assumption that you would set the start() and stop() method calls that we are required to use to gather the required times to calculate the total elapsed time, via the allotted function call, so that I can then output the result to the appropriate stream.
(The method name that I am using here is just a placeholder as not to show the same code that I am using, if only because I, again, just want to have a better understanding.)
Such as (example below):
startclock()
{
m_start = clock_gettime();
}
(Is this anywhere close? If not, please proceed to answer in the field below.)
Answer: //your answer goes here...
How is it supposed to be GENERICALLY implemented?
-------------------------------------------------
//Example goes here...
Again, thank you for any help that you would possibly be able to show me in regards to this program. Thanks a bunch and I hope that all of you have a good day. ttyl.
Regards,
Butterfreedom
(aka. TheFemaleMagusOfDalaran and Nerdrage23)