Write a C/C++/UNIX procedure, getTime ( ), that returns the execution time of code segments by calling

Question:

Write a C/C++/UNIX procedure, getTime ( ), that returns the execution time of code segments by calling it before the code segment is executed and again after the code segment is executed; for example:

double getTime(int); 

start = getTime(-3); 

<code segment>; 

stop = getTime(-3);

elapsedTime = Stop - start; // in milliseconds

Use the UNIX kernel gettimeofday( ) call to read the clock on your host system. The parameter specifies the resolution of the time. If the parameter is i, then the length of time for one time unit is 10i’. (i = 2-3 means return the time in milliseconds and i = 2-6 means return the time in microseconds.) State the smallest clock resolution for which your routine operates properly on your host machine.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: