mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
report some statistics after test execution is completed
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class ApplicationManager {
|
||||
protected static Application ourApplication = null;
|
||||
public static int ourApplicationChanges = 0;
|
||||
|
||||
/**
|
||||
* Gets Application.
|
||||
@@ -38,6 +39,7 @@ public class ApplicationManager {
|
||||
|
||||
private static void setApplication(@NotNull Application instance) {
|
||||
ourApplication = instance;
|
||||
ourApplicationChanges++;
|
||||
CachedSingletonsRegistry.cleanupCachedFields();
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt
|
||||
private final ProgressManager myProgressManager;
|
||||
private volatile boolean myDefaultProjectWasDisposed = false;
|
||||
|
||||
public static int TEST_PROJECTS_OPENED = 0;
|
||||
|
||||
private final Runnable restartApplicationOrReloadProjectTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -718,6 +720,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt
|
||||
synchronized (myOpenProjects) {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
assert !project.isDisposed() : "Must not open already disposed project";
|
||||
TEST_PROJECTS_OPENED++;
|
||||
myTestProjects.add(project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.project.impl.ProjectManagerImpl;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.testFramework.LeakHunter;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
@@ -24,6 +25,8 @@ import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
@@ -61,6 +64,17 @@ public class _LastInSuiteTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||
public void testStatistics() throws Exception {
|
||||
System.out.println("----- TEST STATISTICS -----");
|
||||
System.out.println(String.format("Application reinitializations: %d", ApplicationManager.ourApplicationChanges));
|
||||
System.out.println(String.format("Test projects opened: %d", ProjectManagerImpl.TEST_PROJECTS_OPENED));
|
||||
for (GarbageCollectorMXBean mxBean : ManagementFactory.getGarbageCollectorMXBeans()) {
|
||||
System.out.println(String.format("Garbage collection in memory pool %s: %d ms", mxBean.getName(), mxBean.getCollectionTime()));
|
||||
}
|
||||
System.out.println(String.format("Total classes loaded: %d", ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()));
|
||||
}
|
||||
|
||||
private static void captureMemorySnapshot() {
|
||||
try {
|
||||
Method snapshot = ReflectionUtil.getMethod(Class.forName("com.intellij.util.ProfilingUtil"), "forceCaptureMemorySnapshot");
|
||||
|
||||
Reference in New Issue
Block a user