VOOZH about

URL: https://www.javacodegeeks.com/2014/10/netbeans-8-0s-five-new-performance-hints.html

โ‡ฑ NetBeans 8.0's Five New Performance Hints


NetBeans 8.0 introduces several new Java hints. Although there are a large number of these new hints related to Java Persistence API, I focus on five new hints in the Performance category.

The five new โ€œPerformance Hintsโ€ introduced with NetBeans 8.0 are:
 
 
 
 
 
 

  • Boxing of already boxed value
  • Redundant String.toString()
  • Replace StringBuffer/StringBuilder by String
  • Unnecessary temporary during conversion from String
  • Unnecessary temporary during conversion to String

Each of these five performance-related Java hints are illustrated in this post with screen snapshots taken from NetBeans 8.0 with code that demonstrates these hints. There are two screen snapshots for each hint, one each showing the text displayed when the cursor hovers over the line of code marked with yellow underlining and one each showing the suggested course of action to be applied to address that hint (shown when clicking on the yellow light bulb to the left of the flagged line). Some of the captured screen snapshots include examples of code that avoid the hint.

Boxing of Already Boxed Value

๐Ÿ‘ boxingOfAlreadyBoxedHintDescription

๐Ÿ‘ boxingOfAlreadyBoxedHintAction

Redundant String.toString()

๐Ÿ‘ nb80-redundantStringToStringDescription

๐Ÿ‘ nb80-redundantStringToStringAction

Replace StringBuffer/StringBuilder by String

๐Ÿ‘ nb80-replaceStringBufferBuilderByStringDescription

๐Ÿ‘ nb80-replaceStringBufferBuilderByStringAction

Unnecessary Temporary During Conversion from String

๐Ÿ‘ nb80-unnecessaryTemporaryWhenConvertingFromStringDescription

๐Ÿ‘ nb80-unnecessaryTemporaryWhenConvertingFromStringAction

Unnecessary Temporary During Conversion to String

Unless Iโ€™ve done something incorrectly, there appears to be a minor bug with this hint in that it reports โ€œUnnecessary temporary when converting from Stringโ€ when, in this case, it should really be โ€œUnnecessary temporary when converting to Stringโ€. This is not a big deal as the condition is flagged and the action to fix it seems appropriate.

๐Ÿ‘ nb80-unnecessaryTemporaryWhenConvertingToStringDescription

๐Ÿ‘ nb80-unnecessaryTemporaryWhenConvertingToStringAction

Conclusion

The five performance-related hints introduced by NetBeans 8.0 and illustrated here can help Java developers avoid unnecessary object instantiations and other unnecessary runtime cost. Although the benefit of this optimization as shown in my simple examples is almost negligible, it could lead to much greater savings when used in code with loops that perform these same unnecessary instantiations thousands of times. Even without consideration of the performance benefit, these hints help to remind Java developers and teach developers new to Java about the most appropriate mechanisms for acquiring instances and primitive values.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

๐Ÿ‘ Photo of Dustin Marx
Dustin Marx
October 16th, 2014Last Updated: October 15th, 2014
0 139 1 minute read
Subscribe

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button
Close
wpDiscuz