mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[unit perf tests] AT-617 Report multiple performance test invocation as dedicated test runs
GitOrigin-RevId: fe08fe9bacb06ac292f2c7c9673f012447c746e2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
95095ffeda
commit
873735c9dc
@@ -151,7 +151,8 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
}
|
||||
};
|
||||
|
||||
PlatformTestUtil.startPerformanceTest("getParent before movement", time, checkPerformance).assertTiming(getQualifiedTestMethodName());
|
||||
PlatformTestUtil.startPerformanceTest("getParent before movement", time, checkPerformance)
|
||||
.assertTiming(getQualifiedTestMethodName() + " - getParent before movement");
|
||||
|
||||
VirtualFile dir1 = root.createChildDirectory(this, "dir1");
|
||||
VirtualFile dir2 = root.createChildDirectory(this, "dir2");
|
||||
@@ -159,7 +160,8 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
dir1.createChildData(this, "a" + i + ".txt").move(this, dir2);
|
||||
}
|
||||
|
||||
PlatformTestUtil.startPerformanceTest("getParent after movement", time, checkPerformance).assertTiming(getQualifiedTestMethodName());
|
||||
PlatformTestUtil.startPerformanceTest("getParent after movement", time, checkPerformance)
|
||||
.assertTiming(getQualifiedTestMethodName() + " - getParent after movement");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -281,7 +283,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
eventsForCreating(events, N, temp);
|
||||
assertEquals(N, TempFileSystem.getInstance().list(temp).length); // do not call getChildren which caches everything
|
||||
})
|
||||
.assertTiming(getQualifiedTestMethodName());
|
||||
.assertTiming(getQualifiedTestMethodName() + " - many files creations");
|
||||
|
||||
PlatformTestUtil.startPerformanceTest("many files deletions", 3_300, () -> {
|
||||
assertEquals(N, events.size());
|
||||
@@ -300,7 +302,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
eventsForDeleting(events, temp);
|
||||
assertEquals(N, TempFileSystem.getInstance().list(temp).length); // do not call getChildren which caches everything
|
||||
})
|
||||
.assertTiming(getQualifiedTestMethodName());
|
||||
.assertTiming(getQualifiedTestMethodName() + " - many files deletions");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2050,14 +2050,16 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase {
|
||||
|
||||
PlatformTestUtil.startPerformanceTest("SSR", 20000,
|
||||
() -> assertEquals("Reformat Performance", loadFile("ReformatPerformance_result.java"),
|
||||
replace(source, pattern, replacement, true, true))).assertTiming();
|
||||
replace(source, pattern, replacement, true, true)))
|
||||
.assertTimingAsSubtest();
|
||||
|
||||
options.setToReformatAccordingToStyle(false);
|
||||
options.setToShortenFQN(true);
|
||||
|
||||
PlatformTestUtil.startPerformanceTest("SSR", 20000,
|
||||
() -> assertEquals("Shorten Class Ref Performance", loadFile("ShortenPerformance_result.java"),
|
||||
replace(source, pattern, replacement, true, true))).assertTiming();
|
||||
replace(source, pattern, replacement, true, true)))
|
||||
.assertTimingAsSubtest();
|
||||
}
|
||||
|
||||
public void testLeastSurprise() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.util.io.StorageLockContext;
|
||||
import kotlin.reflect.KFunction;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -169,7 +170,7 @@ public class PerformanceTestInfo {
|
||||
});
|
||||
}
|
||||
|
||||
public void assertTiming() {
|
||||
private static Method getCallingTestMethod() {
|
||||
Method callingTestMethod = tryToFindCallingTestMethodByJUnitAnnotation();
|
||||
|
||||
if (callingTestMethod == null) {
|
||||
@@ -181,17 +182,54 @@ public class PerformanceTestInfo {
|
||||
}
|
||||
}
|
||||
|
||||
assertTiming(callingTestMethod);
|
||||
return callingTestMethod;
|
||||
}
|
||||
|
||||
/** @see PerformanceTestInfo#assertTiming(String) */
|
||||
public void assertTiming() {
|
||||
assertTiming(getCallingTestMethod());
|
||||
}
|
||||
|
||||
public void assertTiming(@NotNull Method javaTestMethod) {
|
||||
assertTiming(String.format("%s.%s", javaTestMethod.getDeclaringClass().getName(), javaTestMethod.getName()));
|
||||
assertTiming(javaTestMethod, "");
|
||||
}
|
||||
|
||||
public void assertTiming(@NotNull Method javaTestMethod, @Nullable String subTestName) {
|
||||
var fullTestName = String.format("%s.%s", javaTestMethod.getDeclaringClass().getName(), javaTestMethod.getName());
|
||||
if (subTestName != null && !subTestName.isEmpty()) {
|
||||
assert !subTestName.isEmpty() : "Sub test name either should be null or NOT empty string";
|
||||
fullTestName += " - " + subTestName;
|
||||
}
|
||||
assertTiming(fullTestName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link PerformanceTestInfo#assertTiming(String)}
|
||||
* <br/>
|
||||
* Eg: <code>assertTiming(GradleHighlightingPerformanceTest::testCompletionPerformance)</code>
|
||||
*/
|
||||
public void assertTiming(@NotNull KFunction<?> kotlinTestMethod) {
|
||||
assertTiming(String.format("%s.%s", kotlinTestMethod.getClass().getName(), kotlinTestMethod.getName()));
|
||||
}
|
||||
|
||||
/** @see PerformanceTestInfo#assertTimingAsSubtest(String) */
|
||||
public void assertTimingAsSubtest() {
|
||||
assertTimingAsSubtest(what);
|
||||
}
|
||||
|
||||
/** In case if you want to run many subsequent performance measurements in your JUnit test */
|
||||
public void assertTimingAsSubtest(@Nullable String subTestName) {
|
||||
assertTiming(getCallingTestMethod(), subTestName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts expected timing.
|
||||
* For Java you can use {@link com.intellij.testFramework.UsefulTestCase#getQualifiedTestMethodName()}
|
||||
* OR
|
||||
* {@link com.intellij.testFramework.fixtures.BareTestFixtureTestCase#getQualifiedTestMethodName()}
|
||||
*
|
||||
* @param fullQualifiedTestMethodName - String representation of full method name.
|
||||
*/
|
||||
public void assertTiming(String fullQualifiedTestMethodName) {
|
||||
assertTiming(IterationType.WARMUP, fullQualifiedTestMethodName);
|
||||
assertTiming(IterationType.MEASURE, fullQualifiedTestMethodName);
|
||||
|
||||
@@ -908,6 +908,10 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
return name == null ? "" : PlatformTestUtil.getTestName(name, lowercaseFirstLetter);
|
||||
}
|
||||
|
||||
public final @NotNull String getQualifiedTestMethodName() {
|
||||
return String.format("%s.%s", this.getClass().getName(), getName());
|
||||
}
|
||||
|
||||
protected @NotNull String getTestDirectoryName() {
|
||||
return getTestName(true).replaceAll("_.*", "");
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package com.intellij.tools.ide.metrics.benchmark
|
||||
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import com.intellij.openapi.application.ApplicationInfo
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.util.BuildNumber
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.platform.testFramework.diagnostic.MetricsPublisher
|
||||
import com.intellij.teamcity.TeamCityClient
|
||||
@@ -72,7 +72,7 @@ class IJPerfMetricsPublisherImpl : MetricsPublisher {
|
||||
projectURL = "",
|
||||
projectDescription = "",
|
||||
methodName = fullQualifiedTestMethodName,
|
||||
buildNumber = ApplicationInfo.getInstance().build,
|
||||
buildNumber = BuildNumber.currentVersion(),
|
||||
metrics = metrics,
|
||||
buildInfo = buildInfo
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DomPerformanceTest extends DomHardCoreTestCase {
|
||||
}
|
||||
ref.set(element);
|
||||
}))
|
||||
.assertTiming();
|
||||
.assertTimingAsSubtest();
|
||||
|
||||
MyElement newElement = createElement(DomUtil.getFile(ref.get()).getText(), MyElement.class);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DomPerformanceTest extends DomHardCoreTestCase {
|
||||
public void visitDomElement(DomElement element) {
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
})).assertTiming();
|
||||
})).assertTimingAsSubtest();
|
||||
}
|
||||
|
||||
public void testShouldntParseNonDomFiles() throws Throwable {
|
||||
|
||||
Reference in New Issue
Block a user