1 we must determine how much time is required to

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ounter and lo to the low-order 32 bits. Implementing access counter is a simple exercise in using the embedded assembly feature of GCC , as described in Section 3.15. The code is shown in Figure 9.9. Based on this routine, we can now implement a pair of functions that can be used to measure the total number of cycles that elapse between any two time points: #include "clock.h" void start counter(); double get counter(); Returns: number of cycles since last call to start counter We return the time as a double to avoid the possible overflow problems of using just a 32-bit integer. The code for these two routines is also shown in Figure 9.9. It builds on our understanding of unsigned arithmetic to perform the double-precision subtraction and to convert the result to a double. 9.4 Measuring Program Execution Time with Cycle Counters Cycle counters provide a very precise tool for measuring the time that elapses between two different points in the execution of a program. Typically, however, we are interested in measuring the time required to execute some particular piece of code. Our cycle counter routines compute the total number of cycles between...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online