I want to know if a method from StringUtils from the Apache Commons Lang library is faster than Java String methods.
I know that this is micro-optimization, but it is necessary because the methods will be executed millions of times.
Methods that use regular expression in Java, for example, split()or string comparison with equals().
split()
equals()
StringUtils#splitfaster than String#split.
StringUtils#split
String#split
String#equalsfaster than StringUtils#equals.
String#equals
StringUtils#equals
Java String StringUtils , . . , , , , , .
String
StringUtils
, , , ! .
, , , , .
, , . , ,
return s1 == s2 || (s1 == null && s2 == null) || (s1 != null && s1.equals( s2 ) );
, , , hotspot . , , , .
, , , System.currentTimeMillis() , ; , , .
System.currentTimeMillis()
, , Apache Commons " ", , .
JVM.
, . , - . , ( , , ..). JVM. " " , .
, , . , , , .
-, ? ?
-, ? , , , .
, , . , , , . , String.equals - String. , equals true ==, . , , , , .
==
? ? , . , . " ?" , . , , , , .
. StringUtils String, . StringUtils String. , , .