From 191bc0b81f8f763dc3fb67bc63adf703dc4e2897 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 8 Mar 2018 16:30:35 +0100 Subject: [PATCH] don't execute more performance test iterations than needed --- .../testFramework/PerformanceTestInfo.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java b/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java index 91586a2a5ebd..88400c972b65 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java +++ b/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java @@ -4,6 +4,7 @@ package com.intellij.testFramework; import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory; import com.intellij.concurrency.JobSchedulerImpl; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.ExceptionUtil; import com.intellij.util.ThrowableRunnable; import junit.framework.AssertionFailedError; import org.jetbrains.annotations.Contract; @@ -104,6 +105,7 @@ public class PerformanceTestInfo { } boolean testShouldPass = false; + String logMessage; while (true) { attempts--; @@ -113,10 +115,8 @@ public class PerformanceTestInfo { PlatformTestUtil.waitForAllBackgroundActivityToCalmDown(); data = CpuUsageData.measureCpuUsage(test); } - catch (RuntimeException | Error throwable) { - throw throwable; - } catch (Throwable throwable) { + ExceptionUtil.rethrowUnchecked(throwable); throw new RuntimeException(throwable); } @@ -128,34 +128,29 @@ public class PerformanceTestInfo { testShouldPass |= iterationResult != IterationResult.slow; - String logMessage = formatMessage(data, expectedOnMyMachine, iterationResult); + logMessage = formatMessage(data, expectedOnMyMachine, iterationResult); if (iterationResult == IterationResult.acceptable) { TeamCityLogger.info(logMessage); System.out.println("\nSUCCESS: " + logMessage); - return; } - - if (iterationResult == IterationResult.borderline) { + else { TeamCityLogger.warning(logMessage, null); System.out.println("\nWARNING: " + logMessage); - continue; // maybe next iteration will be totally acceptable } - if (attempts == 0) { + if (attempts == 0 || iterationResult == IterationResult.acceptable) { if (testShouldPass) return; throw new AssertionFailedError(logMessage); } - // try one more time - System.gc(); - System.gc(); - System.gc(); - String s = logMessage + "\n " + attempts + " attempts remain"; + // try again + String s = " " + attempts + " attempts remain"; TeamCityLogger.warning(s, null); - if (UsefulTestCase.IS_UNDER_TEAMCITY) { - System.err.println(s); - } + System.out.println(s); + System.gc(); + System.gc(); + System.gc(); } }