diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/MinusculeMatcherPerformanceTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/MinusculeMatcherPerformanceTest.java index 696c67f759b7..dbb8a66a4674 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/MinusculeMatcherPerformanceTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/MinusculeMatcherPerformanceTest.java @@ -8,11 +8,9 @@ import com.intellij.tools.ide.metrics.benchmark.Benchmark; import com.intellij.util.containers.ContainerUtil; import junit.framework.TestCase; import org.jetbrains.annotations.NonNls; -import org.junit.Assert; import java.util.ArrayList; import java.util.List; -import java.util.function.ToIntFunction; public class MinusculeMatcherPerformanceTest extends TestCase { public void testPerformance() { @@ -30,39 +28,54 @@ public class MinusculeMatcherPerformanceTest extends TestCase { Benchmark.newBenchmark("Matching", () -> { for (int i = 0; i < 100_000; i++) { for (MinusculeMatcher matcher : matching) { - Assert.assertTrue(matcher.matches(longName)); + assertTrue(matcher.matches(longName)); matcher.matchingDegree(longName); } for (MinusculeMatcher matcher : nonMatching) { - Assert.assertFalse(matcher.matches(longName)); + assertFalse(matcher.matches(longName)); } } }).runAsStressTest().start(); } public void testOnlyUnderscoresPerformance() { + String small = StringUtil.repeat("_", 50000); + String smallWildcard = "*" + small; + MinusculeMatcher smallMatcher = NameUtil.buildMatcher(smallWildcard, NameUtil.MatchingCaseSensitivity.NONE); + String big = StringUtil.repeat("_", small.length() + 1); + String bigWildcard = "*" + big; + MinusculeMatcher bigMatcher = NameUtil.buildMatcher(big, NameUtil.MatchingCaseSensitivity.NONE); Benchmark.newBenchmark(getName(), () -> { - String small = StringUtil.repeat("_", 50000); - String big = StringUtil.repeat("_", small.length() + 1); - assertMatches("*" + small, big); - assertDoesntMatch("*" + big, small); + for (int i = 0; i < 10_000; i++) { + assertMatches(smallMatcher, smallWildcard, big); + assertDoesntMatch(bigMatcher, bigWildcard, small); + } }).runAsStressTest().start(); } public void testRepeatedLetterPerformance() { + String big = StringUtil.repeat("Aaaaaa", 50000); + String pattern = "aaaaaaaaaaaaaaaaaaaaaaaa"; + MinusculeMatcher matcher = NameUtil.buildMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE); + String mismatchPattern = "aaaaaaaaaaaaaaaaaaaaaaaab"; + MinusculeMatcher mismatchMatcher = NameUtil.buildMatcher(mismatchPattern, NameUtil.MatchingCaseSensitivity.NONE); Benchmark.newBenchmark(getName(), () -> { - String big = StringUtil.repeat("Aaaaaa", 50000); - assertMatches("aaaaaaaaaaaaaaaaaaaaaaaa", big); - assertDoesntMatch("aaaaaaaaaaaaaaaaaaaaaaaab", big); + for (int i = 0; i < 1_000; i++) { + assertMatches(matcher, pattern, big); + assertDoesntMatch(mismatchMatcher, mismatchPattern, big); + } }).runAsStressTest().start(); } public void testMatchingLongHtmlWithShortHtml() { + String pattern = "*
aaa
java.lang.Objectcom.maverick.ssh.cipher.SshCipher
com.maverick.ssh.crypto.engines.CbcBlockCipher
com.sshtools.cipher.AES128Cbc
This cipher can optionally be added to the J2SSH Maverick API. To add the ciphers from this package simply add them to the Ssh2Context
import com.sshtools.cipher.*;