Unformatted text preview:

Performance MeasurementPerformance AnalysisPaper and pencil.Don’t need a working computer program or even a computer.Some Uses Of Performance Analysis¾determine practicality of algorithm¾predict run time on large instance¾compare 2 algorithms that have different asymptotic complexity¾e.g., O(n) and O(n2)Limitations of AnalysisDoesn’t account for constant factors.but constant factor may dominate1000n vs n2and we are interested only inn < 1000Limitations of AnalysisModern computers have a hierarchical memory organization with different access time for memory at different levels of the hierarchy.Memory HierarchyRL1L2MAINALU8-32 32KB 512KB 512MB1C 2C 10C 100CLimitations of AnalysisOur analysis doesn’t account for this difference in memory access times.Programs that do more work may take less time than those that do less work.Performance MeasurementMeasure actual time on an actual computer.What do we need?Performance Measurement Needs●programming language● working program● computer● compiler and options to usejavac -oPerformance Measurement Needs● data to use for measurementworst-case databest-case dataaverage-case data● timing mechanism --- clockTiming In Javalong startTime = System.currentTimeMillis();// gives time in milliseconds since 1/1/1970 GMT// code to be timed comes herelong elapsedTime = System.currentTimeMillis()- startTime;ShortcomingClock accuracyassume 100 millisecondsRepeat work many times to bring total time to be >= 1 secondAccurate Timinglong startTime = System.currentTimeMillis();long counter;do {counter++;doSomething();} while (System.currentTimeMillis() -startTime < 1000)long elapsedTime = System.currentTimeMillis()- startTime;float timeForMethod =((float) elapsedTime)/counter;AccuracyNow accuracy is 10%.first reading may be just about to change tostartTime + 100second reading may have just changed tofinishTimeso finishTime - startTime is off by 100msAccuracyfirst reading may have just changed tostartTimesecond reading may be about to change tofinishTime + 100so finishTime - startTime is off by 100msAccuracyExamining remaining cases, we gettrueElapsedTime =finishTime - startTime +- 100msTo ensure 10% accuracy, requireelapsedTime = finishTime – startTime>= 1secWhat Went Wrong?long startTime = System.currentTimeMillis();long counter;do {counter++;InsertionSort.insertionSort(a);} while (System.currentTimeMillis() -startTime < 1000)long elapsedTime = System.currentTimeMillis()- startTime;float timeForMethod =((float) elapsedTime)/counter;The Fixlong startTime = System.currentTimeMillis();long counter;do {counter++;// put code to initialize a[] hereInsertionSort.insertionSort(a);} while (System.currentTimeMillis() -startTime < 1000)Time Shared SystemUNIXtime MyProgramBad Way To Timedo {counter++;startTime = System.currentTimeMillis();doSomething();elapsedTime +=System.currentTimeMillis()- startTime;} while (elapsedTime <


View Full Document

UF COP 3530 - Performance Measurement

Download Performance Measurement
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Performance Measurement and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Performance Measurement 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?