Github user trkurc commented on the pull request: https://github.com/apache/nifi/pull/202#issuecomment-179579922 @taftster - code readability is subjective, I prefer actually prefer what is in the PR. The String.format makes it an order of magnitude slower based on my initial tests. I see no appreciable difference between StringBuffer and StringBuilder The results of the below code: `` 1 ===== 304 elapsed 2 ===== 1717 elapsed 3 ===== 248 elapsed ``` The StringBuffer is faster, but it is likely due to some of the JVM string magic. ```java int iter = 1<<20; AtomicLong ai = new AtomicLong(0); long now = System.currentTimeMillis(); for(int i=0; i < iter; i++) { final String s=Long.toHexString(ai.getAndIncrement()); String x2 = new StringBuilder("00000000-0000-0000-0000000000000000".substring(0,(35-s.length()))+s).insert(23, '-').toString(); } System.out.printf("1 ===== %d elapsed\n", (System.currentTimeMillis() - now )); now = System.currentTimeMillis(); for(int i=0; i < iter; i++) { String x2 = new StringBuilder() .append("00000000-0000-0000-") .append(String.format("%016x", ai.getAndIncrement())) .insert(23, '-') .toString(); } System.out.printf("2 ===== %d elapsed\n", (System.currentTimeMillis() - now )); now = System.currentTimeMillis(); for(int i=0; i < iter; i++) { final String s=Long.toHexString(ai.getAndIncrement()); String x2 = new StringBuffer("00000000-0000-0000-0000000000000000".substring(0,(35-s.length()))+s).insert(23, '-').toString(); } System.out.printf("3 ===== %d elapsed\n", (System.currentTimeMillis() - now )); ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---