Posts

Showing posts from November, 2014

String Concatenation vs StringBuilder Performance Benchmark

Image
This single Java class benchmark, shows impressively that the penalty for using StringBuilder instead of regular String concatenation can be around 5x ! Many static code analyzers like PMD / SonarQube deceptively claim the opposite. This assumption might be a vestige from the pre Java 5 era. Indeed some developers even concatenate compile time constants ( static final ) using StringBuilder. Although be warned , when it comes to using effectively non-final variables inside the concatenation, StringBuilder will drastically outperform the regular String concatenation by several orders of magnitude. Effectively non-final variables are references that are not fixed. On the other hand effectively final values do not necessarily need be prefixed with the " final " keyword but they could be , which differentiates them from effectively non-final variables, that cannot be prefixed with the " final " keyword without causing a compilation error. To state it clear &

Difference Between a Parameter & Argument

Image
A parameter is part of a method's signature declaration and is used as a receiving container for an argument . An argument is an actual value literal that is passed to a method that performs operations based on and an arguments value. This graphic illustrates the difference:

Disable Java bytecode verification to speedup app startup time

Image
To do so, add -Xverify:none or -noverify  as a parameter when executing an app: java -jar -Xverify:none MyApp For security reasons this is highly discouraged in production systems and should be used in development environments only (if at all).

Flush / Reset DNS Cache on Mac OS X

Image
If you want to reset / flush the DNS cache on Mac OS X Mavericks or Yosemite use this command: dscacheutil -flushcache