Subj : Re: Solaris real-time thread capabilities To : comp.unix.solaris,comp.programming.threads From : capnwhit Date : Tue Sep 06 2005 05:51 pm Hello Eric, Here's a quick hack... that shows the max diff between successive invocations of gethrtime(). I may try the histogram approach suggested by Chris Friesen. BEGIN SAMPLE CODE ============================================ #include #include int main(int argc, char* argv[]) { const int ARG_SECONDS = 1; const int ARG_NUMBER = 2; if(argc != ARG_NUMBER) { std::cout << "Usage: " << argv[0] << " number_of_seconds" << std::endl; exit(1); } long CONVERT_SECONDS_TO_NS = 1000000000; int numberOfSecondsForTest = atoi(argv[ARG_SECONDS]); hrtime_t startTime = gethrtime(); hrtime_t endTime = startTime + numberOfSecondsForTest * CONVERT_SECONDS_TO_NS; hrtime_t t1 = 0; hrtime_t t2 = 0; hrtime_t diff = 0; hrtime_t cummulativeDiff = 0; hrtime_t averageDiff = 0; hrtime_t maxDiff = 0; long numCyclesInsideSpinLoop = 0; hrtime_t currentTime = gethrtime(); while(currentTime < endTime) { numCyclesInsideSpinLoop += 1; t1 = gethrtime(); t2 = gethrtime(); diff = t2 - t1; cummulativeDiff += diff; averageDiff = cummulativeDiff / numCyclesInsideSpinLoop; if(diff > maxDiff) { maxDiff = diff; std::cout << "NEW MAXIMUM VALUE: maxDiff = " << maxDiff << ", averageDiff = " << averageDiff << std::endl; } currentTime = gethrtime(); } } ============================================ END SAMPLE CODE .