Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] URIUtils performance

Hi,

The new version of URIUtils.canonicalPath is "cleaner" but from my JMH benckmark :
- previous implementation : 12 Mops/s
- new implementation : 1 Mops/s

By replacing :
List<String> directories = new ArrayList<>();
Collections.addAll(directories, __PATH_SPLIT.split(path));

by a faster split method like :
public static final List<String> fastSplit(final String string, final char sep) {
final List<String> l = new ArrayList<String>();
final int length = string.length();
final char[] cars = string.toCharArray();
int rfirst = 0;
for (int i = 0; i < length; i++) {
if (cars[i] == sep) {
l.add(new String(cars, rfirst, i - rfirst + 1));
rfirst = i + 1;
}
}

if (rfirst < length) {
l.add(new String(cars, rfirst, length - rfirst + 1));
}
return l;
}

performance are 3Mops/s .

A faster iterator can boost performance too. Are you interested by such improvments?
If yes, I have some hours to spend on it.

Best regards,

Guillaume


Back to the top