0

hello people
i was wondering if anyone could come up with a program that could excatly compute the amount of time that it takes for a simple arthimetic operation. I mean lets assume that there is a simple addition program, is it possible to find the exact amount of time that it took for the computation for addition..

anticipating your replies.
cheers!!!!

jack

5
Contributors
7
Replies
8
Views
12 Years
Discussion Span
Last Post by chrisbliss18
0

Computers don't keep exact time and don't keep infinitely precise measurements of time. If you are wanting measurements of time greater than a few milliseconds and you are on a Windows system, you can use the GetTickCount function. Record the value returned by the function before and after you execute the code that you want to time, subtract the first value from the second, and you have the number of milliseconds that have elapsed.

0

whenevr i need to check the computation time of my program segments....i go for gcc compiler...and compile the program using profiling option...it gives complete description of all the blocks(time taken...how many times a particular block is called and many other useful things etc....)

0

hey..
What is ur purpose for knowing the computation time?? If its an ideal code then u will have to code directly in assembly to idealise ur coding.. compilers generally break an instruction in a standard manner.. e.g if u say 2*x it will multiply 2 by x and not add x to itself which will reduce the computation time..

0

hey..
What is ur purpose for knowing the computation time?? If its an ideal code then u will have to code directly in assembly to idealise ur coding.. compilers generally break an instruction in a standard manner.. e.g if u say 2*x it will multiply 2 by x and not add x to itself which will reduce the computation time..

hey
Thankz guys for the replies.. This was a question that was given to me as assignment. My prof wanted us to calculate the amount of time it takes to do a simple arithmetic operation. I did use all the time function available. But time functions shows only micro seconds value. The time taken for addition is so slow that everytime i run the program it says 0.00seconds...so now am looking for somethin that would calculate time in nanoseconds

thanks again

0

Suppose you want to measure the thickness of a sheet of paper. Don't put a ruler next to the sheet of paper and use a microscope; put a ruler next to a stack of one hundred sheets of paper and use your eyes.

0

Yay... I helped a guy with a homework assignment. Read my orignial post, then read Rashakil Fol's post above mine, and then think about the problem. We gave you the answer, you just need to piece it together. Since it is a homework assignment, you should have to think about it a bit.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.