0
How Fast is Your Java       Code?   Performance micro-benchmarking           Dmitry Buzdin
About Speaker                buzdin@gmail.com                @buzdinDmitry Buzdin
Motivation
Programming for  Performance
SituationSome developers optimize code a lotGood habits like:* Putting final keyword* Optimizing assignments* Creating les...
SituationArguing who’s code is faster
So how do youmeasure that?
Macro-benchmarking     vs   Micro-benchmarking
Challenge
Challenge: How Fast is           That?System.out.println("Hello, World!");
DEMO
1 millisecond = 1 000 microseconds =1 000 000 nanoseconds
Test NoiseClassloader activitiesReflection inflationGarbage collectionJIT compilation
JIT CompilerBehavior-drivenCan compile and “de-compile”Client and Ser ver JITs are different
Getting JVM StatsManagementFactory.getXYZBean()
ClassLoadingMXBeanGarbageCollectorMXBeanRuntimeMXBeanMemoryMXBeanThreadMXBean...
Measurement PitfallsMeasuring in millisecondsNot doing warm-upsNot doing enough warm-upsWrong JVM settingsToo few iterations
Conclusions
ConclusionsDo not do micro optimizationsWrite first - then measure criticalplacesProgram readability is more importantDo p...
“We should forget about small efficiencies, say about 97% of thetime: premature optimization is the           root of all ...
Some Resources  http://www.ibm.com/developer works/java/library/j-benchmark2/                            index.htmlhttp://...
Code is on GitHubhttps://github.com/buzdin/java-microbenchmarking/
The End
Upcoming SlideShare
Loading in...5
×

How Fast is Your Java Code

609

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
609
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "How Fast is Your Java Code"

  1. 1. How Fast is Your Java Code? Performance micro-benchmarking Dmitry Buzdin
  2. 2. About Speaker buzdin@gmail.com @buzdinDmitry Buzdin
  3. 3. Motivation
  4. 4. Programming for Performance
  5. 5. SituationSome developers optimize code a lotGood habits like:* Putting final keyword* Optimizing assignments* Creating less objects* Avoiding reflection
  6. 6. SituationArguing who’s code is faster
  7. 7. So how do youmeasure that?
  8. 8. Macro-benchmarking vs Micro-benchmarking
  9. 9. Challenge
  10. 10. Challenge: How Fast is That?System.out.println("Hello, World!");
  11. 11. DEMO
  12. 12. 1 millisecond = 1 000 microseconds =1 000 000 nanoseconds
  13. 13. Test NoiseClassloader activitiesReflection inflationGarbage collectionJIT compilation
  14. 14. JIT CompilerBehavior-drivenCan compile and “de-compile”Client and Ser ver JITs are different
  15. 15. Getting JVM StatsManagementFactory.getXYZBean()
  16. 16. ClassLoadingMXBeanGarbageCollectorMXBeanRuntimeMXBeanMemoryMXBeanThreadMXBean...
  17. 17. Measurement PitfallsMeasuring in millisecondsNot doing warm-upsNot doing enough warm-upsWrong JVM settingsToo few iterations
  18. 18. Conclusions
  19. 19. ConclusionsDo not do micro optimizationsWrite first - then measure criticalplacesProgram readability is more importantDo perform macro optimizationsinstead
  20. 20. “We should forget about small efficiencies, say about 97% of thetime: premature optimization is the root of all evil” Donald Knuth
  21. 21. Some Resources http://www.ibm.com/developer works/java/library/j-benchmark2/ index.htmlhttp://stackoverflow.com/questions/504103/how-do-i-write-a-correct- micro-benchmark-in-java http://docs.oracle.com/javase/specs/ jvms/se7 /html/index.html
  22. 22. Code is on GitHubhttps://github.com/buzdin/java-microbenchmarking/
  23. 23. The End
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×