performance measurement performance analysis
play

Performance Measurement Performance Analysis Paper and pencil. - PDF document

Performance Measurement Performance Analysis Paper and pencil. Dont need a working computer program or even a computer. Some Uses Of Performance Analysis Limitations of Analysis Doesnt account for constant factors. determine


  1. Performance Measurement Performance Analysis Paper and pencil. Don’t need a working computer program or even a computer. Some Uses Of Performance Analysis Limitations of Analysis Doesn’t account for constant factors. � determine practicality of algorithm � predict run time on large instance but constant factor may dominate � compare 2 algorithms that have different 1000n vs n 2 asymptotic complexity and we are interested only in � e.g., O(n) and O(n 2 ) n < 1000

  2. Memory Hierarchy Limitations of Analysis Modern computers have a hierarchical memory organization with different access time for MAIN memory at different levels of the L2 hierarchy. L1 ALU R 8-32 32KB 512KB 512MB 1C 2C 10C 100C Performance Measurement Limitations of Analysis Measure actual time on an actual computer. Our analysis doesn’t account for this difference in memory access times. What do we need? Programs that do more work may take less time than those that do less work.

  3. Performance Measurement Needs Performance Measurement Needs ● data to use for measurement worst-case data best-case data ● programming language average-case data ● working program ● computer ● timing mechanism --- clock ● compiler and options to use javac -o Timing In Java Shortcoming long startTime = System.currentTimeMillis(); Clock accuracy // gives time in milliseconds since 1/1/1970 GMT assume 100 milliseconds // code to be timed comes here Repeat work many times to bring total time to be >= 1 second long elapsedTime = System.currentTimeMillis() - startTime;

  4. Accuracy Accurate Timing Now accuracy is 10%. long startTime = System.currentTimeMillis(); long counter; do { first reading may be just about to change to counter++; startTime + 100 doSomething(); } while (System.currentTimeMillis() - second reading may have just changed to startTime < 1000) finishTime long elapsedTime = System.currentTimeMillis() - startTime; so finishTime - startTime is off by 100ms float timeForMethod = ((float) elapsedTime)/counter; Accuracy Accuracy Examining remaining cases, we get first reading may have just changed to startTime trueElapsedTime = finishTime - startTime +- 100ms second reading may be about to change to finishTime + 100 To ensure 10% accuracy, require so finishTime - startTime is off by 100ms elapsedTime = finishTime – startTime >= 1sec

  5. What Went Wrong? The Fix long startTime = System.currentTimeMillis(); long counter; long startTime = System.currentTimeMillis(); do { long counter; counter++; do { InsertionSort.insertionSort(a); counter++; } while (System.currentTimeMillis() - // put code to initialize a[] here startTime < 1000) InsertionSort.insertionSort(a); long elapsedTime = System.currentTimeMillis() } while (System.currentTimeMillis() - - startTime; startTime < 1000) float timeForMethod = ((float) elapsedTime)/counter; Time Shared System Bad Way To Time do { UNIX counter++; time MyProgram startTime = System.currentTimeMillis(); doSomething(); elapsedTime += System.currentTimeMillis() - startTime; } while (elapsedTime < 1000)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend