Great ways to improve java performance

1,301
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,301
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Great ways to improve java performance

  1. 1. www.sainivas.com<br />1<br />
  2. 2. Why performance is so important?<br />Java<br />2<br />www.sainivas.com<br />
  3. 3. Imagine a world where everything is UNLIMITED<br />3<br />www.sainivas.com<br />
  4. 4. Sorry!!You are in a world where everything is LIMITED<br />4<br />www.sainivas.com<br />
  5. 5. Why performance matters?<br />90% of requirements are complex<br />50% of apps share the same server<br />10% increase in end users every day<br />Performance should be planned initially and not inspected later.<br />5<br />www.sainivas.com<br />
  6. 6. Great ways to improveJava Performance<br />By B. Sai Prasad<br />6<br />www.sainivas.com<br />Simple<br />
  7. 7. Introduction<br />Java Puzzles<br />Short program<br />Where is the issue?<br />How to fix?<br />What did you learn?<br />7<br />www.sainivas.com<br />
  8. 8. Puzzle #1<br />8<br />www.sainivas.com<br />
  9. 9. Moral #1new operator creates a new object<br />“new operator can be avoided by re-using byte arrays, or re-using objects”<br />9<br />www.sainivas.com<br />
  10. 10. Puzzle #2<br />10<br />www.sainivas.com<br />
  11. 11. Moral #2Creating a Double from a string takes about 15 times than from a number<br />“Use primitive data types for constructors rather than String objects.”<br />11<br />www.sainivas.com<br />
  12. 12. Puzzle #3<br />12<br />www.sainivas.com<br />
  13. 13. Moral #3length() call in a tight loop can hit performance<br />“String length is pre-computed, stored in a local variable and used it in a tight loop”<br />13<br />www.sainivas.com<br />
  14. 14. Puzzle #4<br />14<br />www.sainivas.com<br />
  15. 15. Moral #4Default constructor is added automatically by compiler.<br />“Generated constructor invokes the super class constructor.”<br />15<br />www.sainivas.com<br />
  16. 16. Puzzle #5<br />16<br />www.sainivas.com<br />
  17. 17. Moral #5Minimize method calls by method inlining<br />“Inlining is done by expanding the inlined method’s code in the code that calls the method”<br />17<br />www.sainivas.com<br />
  18. 18. Puzzle #6<br />18<br />www.sainivas.com<br />
  19. 19. Moral #6System.arraycopy()efficiently copies one array to another<br />“For very short arrays, use of this method may be counterproductive, because of overhead in actually calling the method”<br />19<br />www.sainivas.com<br />
  20. 20. Puzzle #7<br />20<br />www.sainivas.com<br />
  21. 21. Moral #7BufferedReader reads characters in chunks<br />“the read() method found in BufferedReader simply returns characters from a buffer”<br />21<br />www.sainivas.com<br />
  22. 22. Puzzle #8<br />22<br />www.sainivas.com<br />
  23. 23. Moral #8Reuse. Reuse. Reuse.<br />“It is better to reuse the java libraries than creating something new”<br />23<br />www.sainivas.com<br />
  24. 24. Video<br />www.sainivas.com<br />24<br />

×