name performance activity as a noun to make messages look more natural

This commit is contained in:
Alexey Kudravtsev
2017-06-07 12:40:25 +03:00
parent 43271cc9b9
commit e5eca56a78
22 changed files with 44 additions and 46 deletions
@@ -1224,7 +1224,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
text.append(".toString();<caret>}");
configureByText(StdFileTypes.JAVA, text.toString());
PlatformTestUtil.startPerformanceTest("too many tree visitors", 30000, () -> {
PlatformTestUtil.startPerformanceTest("tree visitors", 30000, () -> {
List<HighlightInfo> infos = highlightErrors();
assertEmpty(infos);
type("kjhgas");
@@ -596,10 +596,10 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
ThrowableRunnable test = () -> assertSize(lineCount, findUsages(findModel));
findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).usesAllCPUCores().useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("find usages in global", 400, test).attempts(2).usesAllCPUCores().useLegacyScaling().assertTiming();
findModel.setCustomScope(new LocalSearchScope(psiFile));
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).usesAllCPUCores().useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("find usages in local", 400, test).attempts(2).usesAllCPUCores().useLegacyScaling().assertTiming();
}
finally {
fixture.tearDown();
@@ -47,7 +47,7 @@ public class JavaSmartReformatPerformanceTest extends AbstractJavaFormatterTest
List<TextRange> ranges = ContainerUtil.newArrayList(new TextRange(6682, 6686));
PlatformTestUtil
.startPerformanceTest("Testing smart reformat on big file", 110, getReformatRunnable(file, ranges))
.startPerformanceTest("smart reformat on big file", 110, getReformatRunnable(file, ranges))
.setup(getSetupRunnable(initial, document))
.useLegacyScaling().assertTiming();
@@ -918,7 +918,7 @@ public class SmartPsiElementPointersTest extends CodeInsightTestCase {
String text = StringUtil.repeatSymbol(' ', 100000);
PsiFile file = createFile("a.txt", text);
PlatformTestUtil.startPerformanceTest("", 2000, () -> {
PlatformTestUtil.startPerformanceTest(getTestName(false), 2000, () -> {
List<SmartPsiFileRange> pointers = new ArrayList<>();
for (int i = 0; i < text.length() - 1; i++) {
pointers.add(getPointerManager().createSmartPsiFileRangePointer(file, new TextRange(i, i + 1)));
@@ -213,7 +213,7 @@ public class ResolveClassTest extends ResolveTestCase {
PsiReference ref = configure();
ensureIndexUpToDate();
PlatformTestUtil.startPerformanceTest("exponent?", 500, () -> assertNull(ref.resolve()))
PlatformTestUtil.startPerformanceTest(getTestName(false), 500, () -> assertNull(ref.resolve()))
.attempts(1).assertTiming();
}
@@ -245,7 +245,7 @@ public class ResolveClassTest extends ResolveTestCase {
ensureIndexUpToDate();
System.gc();
PlatformTestUtil.startPerformanceTest("exponent?", 20000, () -> assertNull(ref.resolve()))
PlatformTestUtil.startPerformanceTest(getTestName(false), 20000, () -> assertNull(ref.resolve()))
.attempts(1).assertTiming();
}
@@ -37,7 +37,7 @@ public class JavaOverrideMethodsSearchTest extends LightCodeInsightFixtureTestCa
final PsiMethod method = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiMethod.class);
assertNotNull(method);
final PsiMethod superMethod = method.findDeepestSuperMethods()[0];
PlatformTestUtil.startPerformanceTest("Only local scope should be processed", 100, () -> {
PlatformTestUtil.startPerformanceTest("search in local scope", 100, () -> {
final Collection<PsiMethod> all = OverridingMethodsSearch.search(superMethod, new LocalSearchScope(getFile()), true).findAll();
assertTrue(all.size() == 1);
}).useLegacyScaling().attempts(1).assertTiming();
@@ -482,7 +482,7 @@ NUMBER ('0yabc0')
CharSequence bombed = new SlowCharSequence(text)
ThrowableRunnable cl = { LexerTestCase.printTokens(bombed, 0, new CustomFileTypeLexer(table)) } as ThrowableRunnable
PlatformTestUtil.startPerformanceTest("slow", 10000, cl).useLegacyScaling().assertTiming()
PlatformTestUtil.startPerformanceTest(getTestName(false), 10000, cl).useLegacyScaling().assertTiming()
}
@@ -1130,7 +1130,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
}
markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE);
PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), () -> {
PlatformTestUtil.startPerformanceTest("highlighters lookup", (int)(N*Math.log(N)/1000), () -> {
List<RangeHighlighterEx> list = new ArrayList<>();
CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<>(list);
for (int i=0; i<N-1;i++) {
@@ -1298,7 +1298,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
RangeMarker marker = doc.createRangeMarker(start, end);
markers.add(marker);
}
PlatformTestUtil.startPerformanceTest("RM", 15000, ()->{
PlatformTestUtil.startPerformanceTest("RM.getStartOffset", 15000, ()->{
doc.insertString(0, " ");
for (int i=0; i<1000; i++) {
for (RangeMarker rm : markers) {
@@ -1321,7 +1321,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
RangeMarker marker = doc.createRangeMarker(start, end);
markers.add(marker);
}
PlatformTestUtil.startPerformanceTest("RM", 20000, ()->{
PlatformTestUtil.startPerformanceTest("RM.getStartOffset", 20000, ()->{
doc.insertString(0, " ");
for (int i=0; i<1000; i++) {
for (int j = 0; j < markers.size(); j++) {
@@ -1346,7 +1346,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
RangeMarker marker = doc.createRangeMarker(start, end);
markers.add(marker);
}
PlatformTestUtil.startPerformanceTest("RM", 10000, ()->{
PlatformTestUtil.startPerformanceTest("insert/delete string", 10000, ()->{
for (int i=0; i<15000; i++) {
doc.insertString(0, " ");
doc.deleteString(0, 1);
@@ -1361,7 +1361,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
DocumentEx doc = new DocumentImpl(StringUtil.repeat("blah", 1000));
int N = 100_000;
List<RangeMarker> markers = new ArrayList<>(N);
PlatformTestUtil.startPerformanceTest("RM", 2000, ()->{
PlatformTestUtil.startPerformanceTest("createRM", 2000, ()->{
for (int i = 0; i < N; i++) {
int start = i % doc.getTextLength();
int end = start + 1;
@@ -1384,7 +1384,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
RangeMarker marker = doc.createRangeMarker(start, end);
markers.add(marker);
}
PlatformTestUtil.startPerformanceTest("RM", 2000, ()->{
PlatformTestUtil.startPerformanceTest("processRangeMarkersOverlappingWith", 2000, ()->{
for (int it=0;it<50;it++) {
for (int i=1; i<doc.getTextLength()-1;i++) {
List<RangeMarker> overlaps = new ArrayList<>();
@@ -107,7 +107,7 @@ public class FileTypesTest extends PlatformTestCase {
String name = String.valueOf(i % 10 * 10 + i * 100 + i + 1);
names[i] = name + name + name + name;
}
PlatformTestUtil.startPerformanceTest("ignore perf", 700, () -> {
PlatformTestUtil.startPerformanceTest("isFileIgnored", 700, () -> {
for (int i=0;i<1000;i++) {
for (String name : names) {
myFileTypeManager.isFileIgnored(name);
@@ -349,7 +349,7 @@ public class ProgressIndicatorTest extends LightPlatformTestCase {
}
public void testProgressPerformance() {
PlatformTestUtil.startPerformanceTest("progress", 100, () -> {
PlatformTestUtil.startPerformanceTest("executeProcessUnderProgress", 100, () -> {
EmptyProgressIndicator indicator = new EmptyProgressIndicator();
for (int i=0;i<100000;i++) {
ProgressManager.getInstance().executeProcessUnderProgress(EmptyRunnable.getInstance(), indicator);
@@ -16,7 +16,6 @@
package com.intellij.openapi.util.io;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ThrowableRunnable;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -31,7 +30,7 @@ public class FileUtilPerformanceTest {
public void toCanonicalPath() throws Exception {
assertEquals(myCanonicalPath, FileUtil.toCanonicalPath(myTestPath));
PlatformTestUtil.startPerformanceTest("", 1000, () -> {
PlatformTestUtil.startPerformanceTest("toCanonicalPath", 1000, () -> {
for (int i = 0; i < 1000000; ++i) {
final String canonicalPath = FileUtil.toCanonicalPath(myTestPath, '/');
assert canonicalPath != null && canonicalPath.length() == 18 : canonicalPath;
@@ -43,7 +42,7 @@ public class FileUtilPerformanceTest {
public void toCanonicalPathSimple() throws Exception {
assertEquals(mySimpleTestPath, FileUtil.toCanonicalPath(mySimpleTestPath));
PlatformTestUtil.startPerformanceTest("", 50, () -> {
PlatformTestUtil.startPerformanceTest("toCanonicalPathSimple", 50, () -> {
for (int i = 0; i < 1000000; ++i) {
final String canonicalPath = FileUtil.toCanonicalPath(mySimpleTestPath, '/');
assert canonicalPath != null && canonicalPath.length() == 8 : canonicalPath;
@@ -55,7 +54,7 @@ public class FileUtilPerformanceTest {
public void isAncestor() throws Exception {
assertTrue(FileUtil.isAncestor(myTestPath, myCanonicalPath, false));
PlatformTestUtil.startPerformanceTest("", 4000, () -> {
PlatformTestUtil.startPerformanceTest("isAncestor", 4000, () -> {
for (int i = 0; i < 1000000; ++i) {
assert FileUtil.isAncestor(myTestPath, myCanonicalPath, false);
assert !FileUtil.isAncestor(myTestPath, myCanonicalPath, true);
@@ -123,7 +123,7 @@ public class TokenSetTest {
final TokenSet set = TokenSet.create();
final int shift = new Random().nextInt(500000);
PlatformTestUtil.startPerformanceTest("TokenSet.contains() performance", 25, () -> {
PlatformTestUtil.startPerformanceTest("TokenSet.contains()", 25, () -> {
for (int i = 0; i < 1000000; i++) {
final IElementType next = elementTypes[(i + shift) % elementTypes.length];
assertFalse(set.contains(next));
@@ -669,7 +669,7 @@ public class NameUtilMatchingTest extends UsefulTestCase {
nonMatching.add(NameUtil.buildMatcher(s, NameUtil.MatchingCaseSensitivity.NONE));
}
PlatformTestUtil.startPerformanceTest("Matcher is slow", 4500, () -> {
PlatformTestUtil.startPerformanceTest("Matching", 4500, () -> {
for (int i = 0; i < 100000; i++) {
for (MinusculeMatcher matcher : matching) {
Assert.assertTrue(matcher.toString(), matcher.matches(longName));
@@ -683,7 +683,7 @@ public class NameUtilMatchingTest extends UsefulTestCase {
}
public void testOnlyUnderscoresPerformance() {
PlatformTestUtil.startPerformanceTest("Matcher is exponential", 300, () -> {
PlatformTestUtil.startPerformanceTest(getTestName(false), 300, () -> {
String small = StringUtil.repeat("_", 50);
String big = StringUtil.repeat("_", small.length() + 1);
assertMatches("*" + small, big);
@@ -692,7 +692,7 @@ public class NameUtilMatchingTest extends UsefulTestCase {
}
public void testRepeatedLetterPerformance() {
PlatformTestUtil.startPerformanceTest("Matcher is exponential", 300, () -> {
PlatformTestUtil.startPerformanceTest(getTestName(false), 300, () -> {
String big = StringUtil.repeat("Aaaaaa", 50);
assertMatches("aaaaaaaaaaaaaaaaaaaaaaaa", big);
assertDoesntMatch("aaaaaaaaaaaaaaaaaaaaaaaab", big);
@@ -16,7 +16,6 @@
package com.intellij.ui;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.ui.FilePathSplittingPolicy;
import junit.framework.TestCase;
import org.jetbrains.annotations.NonNls;
@@ -119,7 +118,7 @@ public class FileNameSplittingTest extends TestCase {
public void testPerformance() {
myPolicy = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR;
PlatformTestUtil.startPerformanceTest("FileNameSplitting performance", 70, () -> {
PlatformTestUtil.startPerformanceTest("FileNameSplitting", 70, () -> {
for (int i = 0; i < 100; i++) {
for (int j = 0; j < FILE.getPath().length(); j++)
myPolicy.getPresentableName(FILE, j);
@@ -162,7 +162,7 @@ public class StringEnumeratorTest extends TestCase {
}
};
PlatformTestUtil.startPerformanceTest("PersistentStringEnumerator performance failed", 2500, () -> {
PlatformTestUtil.startPerformanceTest("PersistentStringEnumerator.enumerate", 2500, () -> {
stringCache.addDeletedPairsListener(listener);
for (int i = 0; i < 100000; ++i) {
final String string = createRandomString();
@@ -1729,7 +1729,7 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase {
options.setToShortenFQN(true);
try {
PlatformTestUtil.startPerformanceTest("SSR should work fast", 3500, new ThrowableRunnable() {
PlatformTestUtil.startPerformanceTest("SSR", 3500, new ThrowableRunnable() {
public void run() {
doTest(testName, ext, message);
}
@@ -493,8 +493,8 @@ public class PlatformTestUtil {
* example usage: {@code startPerformanceTest("calculating pi",100, testRunnable).cpuBound().assertTiming();}
*/
@Contract(pure = true) // to warn about not calling .assertTiming() in the end
public static TestInfo startPerformanceTest(@NonNls @NotNull String message, int expectedMs, @NotNull ThrowableRunnable test) {
return new TestInfo(test, expectedMs, message);
public static TestInfo startPerformanceTest(@NonNls @NotNull String what, int expectedMs, @NotNull ThrowableRunnable test) {
return new TestInfo(test, expectedMs, what);
}
public static boolean canRunTest(@NotNull Class testCaseClass) {
@@ -544,16 +544,16 @@ public class PlatformTestUtil {
private ThrowableRunnable setup; // to run before each test
private int usedReferenceCpuCores = 1;
private int attempts = 4; // number of retries if performance failed
private final String message; // to print on fail
private final String what; // to print on fail
private boolean adjustForIO = false; // true if test uses IO, timings need to be re-calibrated according to this agent disk performance
private boolean adjustForCPU = true; // true if test uses CPU, timings need to be re-calibrated according to this agent CPU speed
private boolean useLegacyScaling;
private TestInfo(@NotNull ThrowableRunnable test, int expectedMs, String message) {
private TestInfo(@NotNull ThrowableRunnable test, int expectedMs, @NotNull String what) {
this.test = test;
this.expectedMs = expectedMs;
assert expectedMs > 0 : "Expected must be > 0. Was: "+ expectedMs;
this.message = message;
this.what = what;
}
@Contract(pure = true) // to warn about not calling .assertTiming() in the end
@@ -642,7 +642,7 @@ public class PlatformTestUtil {
"\n Timings: %s" +
"\n Threads: %s" +
"\n GC stats: %s",
message, colorCode, Math.abs(percentage), percentage > 0 ? "more" : "less",
what, colorCode, Math.abs(percentage), percentage > 0 ? "more" : "less",
expectedOnMyMachine, StringUtil.formatDuration(expectedOnMyMachine),
duration, StringUtil.formatDuration(duration),
Timings.getStatistics(),
@@ -110,7 +110,7 @@ public class AntHighlightingTest extends DaemonAnalyzerTestCase {
try {
myIgnoreInfos = true;
PlatformTestUtil.startPerformanceTest("Should be quite performant !", 25000, () -> doDoTest(true, false)).useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("Big ant file highlighting", 25000, () -> doDoTest(true, false)).useLegacyScaling().assertTiming();
}
finally {
myIgnoreInfos = false;
@@ -119,7 +119,7 @@ class GroovyStressPerformanceTest extends LightGroovyTestCase {
myFixture.type 'foo {}\n'
PsiDocumentManager.getInstance(project).commitAllDocuments()
PlatformTestUtil.startPerformanceTest("Reparse is not incremental", 10000, {
PlatformTestUtil.startPerformanceTest(getTestName(false), 10000, {
story.toCharArray().each {
myFixture.type it
PsiDocumentManager.getInstance(project).commitAllDocuments()
@@ -139,7 +139,7 @@ class GroovyStressPerformanceTest extends LightGroovyTestCase {
}
private void measureHighlighting(String text, int time) {
IdeaTestUtil.startPerformanceTest("slow", time, configureAndHighlight(text)).usesAllCPUCores().useLegacyScaling().assertTiming()
IdeaTestUtil.startPerformanceTest(getTestName(false), time, configureAndHighlight(text)).usesAllCPUCores().useLegacyScaling().assertTiming()
}
void testDeeplyNestedClosures() {
@@ -273,7 +273,7 @@ while (true) {
f.canoPath<caret>
}
'''
IdeaTestUtil.startPerformanceTest("slow", 300, configureAndComplete(text)).usesAllCPUCores().useLegacyScaling().assertTiming()
IdeaTestUtil.startPerformanceTest(getTestName(false), 300, configureAndComplete(text)).usesAllCPUCores().useLegacyScaling().assertTiming()
}
void testClosureRecursion() {
@@ -118,7 +118,7 @@ public class DomPerformanceTest extends DomHardCoreTestCase{
final XmlFile file = (XmlFile)getPsiManager().findFile(virtualFile);
assertFalse(file.getNode().isParsed());
assertTrue(StringUtil.isNotEmpty(file.getText()));
PlatformTestUtil.startPerformanceTest("", 100, () -> assertNull(getDomManager().getFileElement(file))).useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("DOM parsing", 100, () -> assertNull(getDomManager().getFileElement(file))).useLegacyScaling().assertTiming();
}
public void testDontParseNamespacedDomFiles() throws Exception {
@@ -68,7 +68,7 @@ public class XmlPerformanceTest extends LightQuickFixTestCase {
doHighlighting();
myEditor.getSelectionModel().setSelection(0,myEditor.getDocument().getTextLength());
PlatformTestUtil.startPerformanceTest("Fix long indent/unindent "+time, time, () -> {
PlatformTestUtil.startPerformanceTest("indent/unindent "+time, time, () -> {
EditorActionManager.getInstance().getActionHandler("EditorIndentSelection").execute(myEditor, DataManager.getInstance().getDataContext());
EditorActionManager.getInstance().getActionHandler("EditorUnindentSelection").execute(myEditor, DataManager.getInstance().getDataContext());
@@ -58,14 +58,14 @@ public class XmlPerformanceFormatterTest extends XmlFormatterTestBase {
}
public void testReformatCodeFragment() throws Exception {
PlatformTestUtil.startPerformanceTest("reformat code fragment is slow", 6300,
PlatformTestUtil.startPerformanceTest("reformat code fragment", 6300,
() -> checkFormattingDoesNotProduceException("performance")).useLegacyScaling().assertTiming();
}
public void testPerformance3() throws Exception {
final FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
try {
PlatformTestUtil.startPerformanceTest("Fix xml formatter performance problem 3", 6800, createTestRunnable()).useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("xml formatter", 6800, createTestRunnable()).useLegacyScaling().assertTiming();
highlight();
@@ -102,7 +102,7 @@ public class XmlPerformanceFormatterTest extends XmlFormatterTestBase {
public void testPerformance4() throws Exception {
final FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
try {
PlatformTestUtil.startPerformanceTest("Fix xml formatter performance problem 4", 20000, createTestRunnable()).useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("xml formatter", 20000, createTestRunnable()).useLegacyScaling().assertTiming();
}
finally {
editorManager.closeFile(editorManager.getSelectedFiles()[0]);
@@ -123,7 +123,7 @@ public class XmlPerformanceFormatterTest extends XmlFormatterTestBase {
public void testPerformance5() throws Exception {
final FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
try {
PlatformTestUtil.startPerformanceTest("Fix xml formatter performance problem 5", 10000, createTestRunnable()).useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("xml formatter", 10000, createTestRunnable()).useLegacyScaling().assertTiming();
}
finally {
final VirtualFile[] selectedFiles = editorManager.getSelectedFiles();
@@ -136,7 +136,7 @@ public class XmlPerformanceFormatterTest extends XmlFormatterTestBase {
public void testPerformance6() throws Exception {
final FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
try {
PlatformTestUtil.startPerformanceTest("Fix xml formatter performance problem 6", 20000, createTestRunnable()).useLegacyScaling().assertTiming();
PlatformTestUtil.startPerformanceTest("xml formatter", 20000, createTestRunnable()).useLegacyScaling().assertTiming();
}
finally {
final VirtualFile[] selectedFiles = editorManager.getSelectedFiles();