I know of two ways of replacing all occurrences of substring in a string.
The regex way (assuming \"substring-to-be-replaced\" doesn\'t include regex specia
Shouldn't you compare replaceAll 2 times? However, for a single invocation it will hardly be measurable. And will you do millions of comparisions?
Then I would expect 'compile' to be faster, but only, if you don't use a constant String without any pattern-rules.
Where is the problem in writing a micro benchmark? Or look up the source.