Your SlideShare is downloading. ×
0
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
How Fast is Your Java Code
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

How Fast is Your Java Code

600

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
600
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×