[test] make Benchmarks run under setInStressTest(true)

+ use either `@StressTestApplication` or a `Benchmark.runAsStressTest` option

GitOrigin-RevId: 1a92dcfe523b575fa2ad03fea3d791aec5376e26
This commit is contained in:
Ruslan Cheremin
2025-08-15 12:05:40 +00:00
committed by intellij-monorepo-bot
parent 5bd4791e9c
commit e713318cd5
8 changed files with 35 additions and 36 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.openapi.roots.impl
import com.intellij.openapi.fileTypes.FileTypeRegistry
@@ -9,12 +9,12 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.findFileOrDirectory
import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry
import com.intellij.tools.ide.metrics.benchmark.Benchmark
import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.UsefulTestCase
import com.intellij.testFramework.junit5.RunInEdt
import com.intellij.testFramework.junit5.TestApplication
import com.intellij.testFramework.rules.ProjectModelExtension
import com.intellij.tools.ide.metrics.benchmark.Benchmark
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
@@ -175,7 +175,10 @@ class IteratingContentUnderExcludedTest {
IoTestUtil.assumeSymLinkCreationIsSupported()
val root = projectModel.baseProjectDir.virtualFileRoot
generateSymlinkExplosion(VfsUtilCore.virtualToIoFile(root), 17)
Benchmark.newBenchmark("traversing non-project roots") { checkIterate(root) }.start()
Benchmark.newBenchmark("traversing non-project roots") { checkIterate(root) }
.runAsStressTest()
.start()
}
companion object {
@@ -1,14 +1,14 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.openapi.vfs.newvfs.persistent
import com.intellij.testFramework.junit5.TestApplication
import com.intellij.testFramework.junit5.StressTestApplication
import com.intellij.tools.ide.metrics.benchmark.Benchmark
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import java.nio.file.Path
@TestApplication
@StressTestApplication
class VFSInitializationBenchmarkTest {
@Test
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.psi.impl.search;
import com.intellij.openapi.util.text.StringUtil;
@@ -44,8 +44,8 @@ public class LowLevelSearchUtilTest extends TestCase {
IntList found = new IntArrayList(new int[]{-1});
CharSequence text = StringUtil.repeat("xxx z ", 1000000);
Benchmark.newBenchmark("processTextOccurrences", ()-> {
for (int i=0; i<10000; i++) {
Benchmark.newBenchmark("processTextOccurrences", () -> {
for (int i = 0; i < 10000; i++) {
found.removeInt(0);
int startOffset = text.length() / 2 + i % 20;
int endOffset = startOffset + 8;
@@ -54,8 +54,10 @@ public class LowLevelSearchUtilTest extends TestCase {
return true;
});
assertTrue(success);
assertEquals(startOffset+","+endOffset, 1, found.size());
assertEquals(startOffset + "," + endOffset, 1, found.size());
}
}).start();
})
.runAsStressTest()
.start();
}
}
@@ -14,11 +14,12 @@ class ConstructorInjectionTest {
fun `light service getService() performance`() {
val componentManager = TestComponentManager()
assertThat(componentManager.getService(BarService::class.java)).isNotNull()
Benchmark.newBenchmark("getService() must be fast for cached service") {
repeat(30_000_000) {
componentManager.getService(BarService::class.java)!!
}
}.start()
}.runAsStressTest().start()
}
@Test
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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.util.containers;
import com.intellij.concurrency.ConcurrentCollectionFactory;
@@ -93,7 +79,9 @@ class ConcurrentBitSetTest {
PlatformTestUtil.assumeEnoughParallelism();
int L = 128;
int N = 10_000;
Benchmark.newBenchmark("testStressFineGrainedSmallSetModifications", () -> tortureParallelSetClear(L, N)).start();
Benchmark.newBenchmark("testStressFineGrainedSmallSetModifications", () -> tortureParallelSetClear(L, N))
.runAsStressTest()
.start();
}
@Test
@@ -103,7 +91,9 @@ class ConcurrentBitSetTest {
// todo ARM64 is slow for some reason
int N = CpuArch.isArm64() ? 300 : 1000;
Benchmark.newBenchmark("testStressCoarseGrainedBigSet", () -> tortureParallelSetClear(L, N)).start();
Benchmark.newBenchmark("testStressCoarseGrainedBigSet", () -> tortureParallelSetClear(L, N))
.runAsStressTest()
.start();
}
private static void tortureParallelSetClear(int L, int N) {
@@ -208,7 +198,8 @@ class ConcurrentBitSetTest {
assertEquals(expectedSum, r);
});
// really must not depend on CPU core number
})/**/.start();
}).runAsStressTest()
.start();
}
@Test
@@ -386,7 +386,9 @@ class MessageBusTest : MessageBusOwner {
for (i in count - 1 downTo 0) {
Disposer.dispose(children[i])
}
}.start()
}
.runAsStressTest()
.start()
}
@Test
@@ -6,7 +6,7 @@ import com.intellij.platform.diagnostic.telemetry.PlatformMetrics
import com.intellij.platform.diagnostic.telemetry.Scope
import com.intellij.platform.diagnostic.telemetry.TelemetryManager
import com.intellij.platform.diagnostic.telemetry.helpers.use
import com.intellij.testFramework.junit5.TestApplication
import com.intellij.testFramework.junit5.StressTestApplication
import com.intellij.tools.ide.metrics.collector.OpenTelemetryJsonMeterCollector
import com.intellij.tools.ide.metrics.collector.metrics.MetricsSelectionStrategy
import com.intellij.tools.ide.metrics.collector.metrics.PerformanceMetrics
@@ -24,7 +24,7 @@ internal val ExtractionMetricsScope: Scope = Scope("ExtractionMetricsScope", Pla
/** Class intentionally named *Perf* (and not a *Performance*) test.
* That way it will not be ignored during Aggregator run */
@TestApplication
@StressTestApplication
class ApplicationMetricsExtractionFromUnitPerfTest {
private val tracer = TelemetryManager.getTracer(ExtractionMetricsScope)
@@ -149,7 +149,7 @@ class SpanExtractionFromUnitPerfTest {
fun runSubTest(subtestName: String) {
Benchmark.newBenchmark(testInfo.testMethod.get().name) {
runBlocking { delay(Random.nextInt(100, 500).milliseconds) }
}.startAsSubtest(subtestName)
}.runAsStressTest().startAsSubtest(subtestName)
}
runSubTest("subtest1")
@@ -161,7 +161,7 @@ class SpanExtractionFromUnitPerfTest {
val spanName = "simple perf test"
val uniqueTestName = Benchmark.newBenchmark(spanName) {
runBlocking { delay(Random.nextInt(100, 500).milliseconds) }
}.run {
}.runAsStressTest().run {
start()
uniqueTestName
}
@@ -177,7 +177,7 @@ class SpanExtractionFromUnitPerfTest {
perfTest = Benchmark.newBenchmark(spanName) {
runBlocking { delay(Random.nextInt(100, 500).milliseconds) }
throw RuntimeException("Exception text")
}
}.runAsStressTest()
perfTest.apply {
warmupIterations(0)
start()