mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make it easier to turn debug mode in testTypingLatencyPerformance
This commit is contained in:
+21
-16
@@ -98,6 +98,7 @@ import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.ui.HintListener;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import com.intellij.util.ref.GCUtil;
|
||||
@@ -117,6 +118,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -1670,18 +1672,21 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testTypingLatencyPerformance() throws Throwable {
|
||||
boolean debug = false;
|
||||
|
||||
@NonNls String filePath = "/psi/resolve/ThinletBig.java";
|
||||
|
||||
configureByFile(filePath);
|
||||
|
||||
type(' ');
|
||||
CompletionContributor.forLanguage(getFile().getLanguage());
|
||||
//long s = System.currentTimeMillis();
|
||||
long s = System.currentTimeMillis();
|
||||
highlightErrors();
|
||||
//long e = System.currentTimeMillis();
|
||||
//System.out.println("Hi elapsed: "+(e-s));
|
||||
if (debug) {
|
||||
System.out.println("Hi elapsed: "+(System.currentTimeMillis() - s));
|
||||
}
|
||||
|
||||
//List<String> dumps = new ArrayList<>();
|
||||
List<String> dumps = new ArrayList<>();
|
||||
|
||||
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
|
||||
int N = Math.max(5, Timings.adjustAccordingToMySpeed(80, false));
|
||||
@@ -1698,17 +1703,17 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
return;
|
||||
}
|
||||
// uncomment to debug what's causing pauses
|
||||
/*
|
||||
AtomicBoolean finished = new AtomicBoolean();
|
||||
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
|
||||
if (!finished.get()) {
|
||||
dumps.add(ThreadDumper.dumpThreadsToString());
|
||||
}
|
||||
}, 10, TimeUnit.MILLISECONDS);
|
||||
*/
|
||||
if (debug) {
|
||||
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
|
||||
if (!finished.get()) {
|
||||
dumps.add(ThreadDumper.dumpThreadsToString());
|
||||
}
|
||||
}, 10, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
type(' ');
|
||||
long end = System.currentTimeMillis();
|
||||
//finished.set(true);
|
||||
finished.set(true);
|
||||
long interruptTime = end - now;
|
||||
interruptTimes[finalI] = interruptTime;
|
||||
assertTrue(codeAnalyzer.getUpdateProgress().isCanceled());
|
||||
@@ -1734,11 +1739,11 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
|
||||
System.out.println("Interrupt times: " + Arrays.toString(interruptTimes));
|
||||
|
||||
/*
|
||||
for (String dump : dumps) {
|
||||
System.out.println("\n\n-----------------------------\n\n" + dump);
|
||||
if (debug) {
|
||||
for (String dump : dumps) {
|
||||
System.out.println("\n\n-----------------------------\n\n" + dump);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
long mean = ArrayUtil.averageAmongMedians(interruptTimes, 3);
|
||||
long avg = Arrays.stream(interruptTimes).sum() / interruptTimes.length;
|
||||
|
||||
Reference in New Issue
Block a user