Introduction to Programming

aniseedsplashSoftware and s/w Development

Aug 15, 2012 (4 years and 11 months ago)

255 views

Software Engineering

Prof. Dr. Bertrand Meyer

March 2007


June 2007

Chair of Software Engineering

Lecture #20: Profiling

NetBeans Profiler 6.0

Software Engineering, lecture #20: Profiling
2

Profiling

Problem



Large programs


Many objects


Multiple threads


Very hard to understand


Performance problems

hard to identify


Goal



Understand
CPU

and
Memory

usage

Software Engineering, lecture #20: Profiling
3

3

80/20 Rule


80% of run
-
time is spent in 20% of the code



Focus on the 20%, since optimization of the 80% will not
provide overall benefit



Programs are too complex, do not spend time optimizing
the thousands of code paths that are not relevant



Use a tool! You do not know the relevant 20%!


Software Engineering, lecture #20: Profiling
4

4

NetBeans Profiler


Gives accurate results of program analysis


Data
-
mining techniques to deal with the large data sets


Free NetBeans module

Software Engineering, lecture #20: Profiling
5

5

Demo


Simple GUI application


Algorithm that sorts an array


Works with inputs of length 50


Gets slow with input of length 500


We will try to find out why!

Software Engineering, lecture #20: Profiling
6

Improving Performance

Now that you have found the hotspots,

how do you optimize your code?


Several ways:


Change algorithms


Cache values


Reduce the amount of drawing per frame


Use the predicted idle time of the program

Software Engineering, lecture #20: Profiling
7

7

Conclusion


Profile before you Optimize!



Get NetBeans at:





http://www.netbeans.org/