MinusculeMatcher: don't make grand claims about slowness on the basis of just one measurement

This commit is contained in:
peter
2014-07-03 16:03:22 +02:00
parent 98aeed646e
commit e4f7dd08d7
@@ -215,8 +215,7 @@ public class MinusculeMatcher implements Matcher {
}
@Nullable
public FList<TextRange> matchingFragments(@NotNull String name) {
long start = System.currentTimeMillis();
private FList<TextRange> calcMatchingFragments(@NotNull String name) {
MatchingState state = myMatchingState.get();
state.initializeState(name);
try {
@@ -224,12 +223,23 @@ public class MinusculeMatcher implements Matcher {
}
finally {
state.releaseState();
if (System.currentTimeMillis() - start > 1000 &&
// if there's little free memory, it might have been the gc affecting the performance
Runtime.getRuntime().freeMemory() > Runtime.getRuntime().totalMemory() * 3 / 10) {
LOG.error("Too long matching: name=" + name + "; prefix=" + new String(myPattern));
}
}
@Nullable
public FList<TextRange> matchingFragments(@NotNull String name) {
long start = System.currentTimeMillis();
FList<TextRange> result = calcMatchingFragments(name);
if (System.currentTimeMillis() - start > 1000 &&
// if there's little free memory, it might have been the gc affecting the performance
Runtime.getRuntime().freeMemory() > Runtime.getRuntime().totalMemory() * 3 / 10) {
start = System.currentTimeMillis();
calcMatchingFragments(name);
if (System.currentTimeMillis() - start > 1000) {
LOG.error("Too long name matching: name=" + name + "; prefix=" + new String(myPattern));
}
}
return result;
}
/**