Java: add control flow performance test case (IDEA-375157)

GitOrigin-RevId: 727c25aa60c6862dcf87d6b9a0dcb7278f2dce3b
This commit is contained in:
Bas Leijdekkers
2025-07-16 10:04:53 +00:00
committed by intellij-monorepo-bot
parent 6e4ed79cc0
commit 92cf2f8dfa
2 changed files with 2462 additions and 3 deletions
File diff suppressed because it is too large Load Diff
@@ -1,16 +1,34 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.codeInsight.psi;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.*;
import com.intellij.psi.controlFlow.ControlFlow;
import com.intellij.psi.controlFlow.ControlFlowFactory;
import com.intellij.psi.controlFlow.ControlFlowUtil;
import com.intellij.psi.controlFlow.LocalsControlFlowPolicy;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
import com.intellij.tools.ide.metrics.benchmark.Benchmark;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NonNls;
public class ControlFlowPerformanceTest extends LightJavaCodeInsightTestCase {
@NonNls private static final String PATH = "/psi/controlFlowPerf/";
public void testManyLocalVariables() {
configureByFile(PATH + getTestName(false) + ".java");
PsiFile file = getFile();
Benchmark.newBenchmark(getTestName(false), () -> {
PsiTreeUtil.processElements(file, element -> {
if (element instanceof PsiLocalVariable var) {
final PsiCodeBlock scope = PsiTreeUtil.getParentOfType(var, PsiCodeBlock.class);
ControlFlowUtil.isEffectivelyFinal(var, scope);
}
return true;
});
}).start();
}
public void testHugeMethodChainControlFlow() {
Benchmark.newBenchmark(getTestName(false), () -> {
int size = 2500;