// To compute elapsed time (as if you used a stopwatch) // instead of the sum of the time that each thread used, // put this at the top of your file: #include #include // Declare these variables: double myelapsed ; // used for timing struct timeval myt0, myt1; // To begin timing: gettimeofday (&myt0 , NULL ); < put code to time here > // To end timing: gettimeofday (&myt1 , NULL ); // To comput the elapsed time: myelapsed = (double)( myt1.tv_sec -myt0.tv_sec ); myelapsed += (double)( myt1.tv_usec -myt0.tv_usec )/1.e6; // Print the result. printf("Time = %f.\n", myelapsed);