mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
moved computeMedian
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -36,8 +36,8 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -129,7 +129,7 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
System.out.println("Average among the N/3 median times: " + PlatformTestUtil.averageAmongMedians(time, 3) + "ms");
|
||||
System.out.println("Average among the N/3 median times: " + ArrayUtil.averageAmongMedians(time, 3) + "ms");
|
||||
|
||||
//System.out.println("JobLauncher.COUNT = " + JobLauncher.COUNT);
|
||||
//System.out.println("JobLauncher.TINY = " + JobLauncher.TINY_COUNT);
|
||||
@@ -205,7 +205,7 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles();
|
||||
|
||||
System.out.println("Average among the N/3 median times: " + PlatformTestUtil.averageAmongMedians(time, 3) + "ms");
|
||||
System.out.println("Average among the N/3 median times: " + ArrayUtil.averageAmongMedians(time, 3) + "ms");
|
||||
}
|
||||
|
||||
public void testRandomEditingForUnused() throws Exception {
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ public class ProgressIndicatorTest extends LightPlatformTestCase {
|
||||
alarm.cancelAllRequests();
|
||||
}
|
||||
}, "", false, getProject(), null, "");
|
||||
long averageDelay = PlatformTestUtil.averageAmongMedians(times.toNativeArray(), 5);
|
||||
long averageDelay = ArrayUtil.averageAmongMedians(times.toNativeArray(), 5);
|
||||
System.out.println("averageDelay = " + averageDelay);
|
||||
assertTrue(averageDelay < CoreProgressManager.CHECK_CANCELED_DELAY_MILLIS *3);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -415,19 +415,6 @@ public class PlatformTestUtil {
|
||||
return new TestInfo(test, expectedMs,message);
|
||||
}
|
||||
|
||||
// calculates average of the median values in the selected part of the array. E.g. for part=3 returns average in the middle third.
|
||||
public static long averageAmongMedians(@NotNull long[] time, int part) {
|
||||
assert part >= 1;
|
||||
int n = time.length;
|
||||
Arrays.sort(time);
|
||||
long total = 0;
|
||||
for (int i= n /2- n / part /2; i< n /2+ n / part /2; i++) {
|
||||
total += time[i];
|
||||
}
|
||||
int middlePartLength = n / part;
|
||||
return middlePartLength == 0 ? 0 : total / middlePartLength;
|
||||
}
|
||||
|
||||
public static boolean canRunTest(@NotNull Class testCaseClass) {
|
||||
if (!SKIP_SLOW && !SKIP_HEADLESS) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.concurrency.JobSchedulerImpl;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
@@ -49,7 +50,7 @@ public class Timings {
|
||||
for (int i=0; i< N; i++) {
|
||||
elapsed[i] = measureCPU();
|
||||
}
|
||||
CPU_TIMING = PlatformTestUtil.averageAmongMedians(elapsed, 2);
|
||||
CPU_TIMING = ArrayUtil.averageAmongMedians(elapsed, 2);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < IO_PROBES; i++) {
|
||||
|
||||
@@ -900,4 +900,17 @@ public class ArrayUtil extends ArrayUtilRt {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// calculates average of the median values in the selected part of the array. E.g. for part=3 returns average in the middle third.
|
||||
public static long averageAmongMedians(@NotNull long[] time, int part) {
|
||||
assert part >= 1;
|
||||
int n = time.length;
|
||||
Arrays.sort(time);
|
||||
long total = 0;
|
||||
for (int i= n /2- n / part /2; i< n /2+ n / part /2; i++) {
|
||||
total += time[i];
|
||||
}
|
||||
int middlePartLength = n / part;
|
||||
return middlePartLength == 0 ? 0 : total / middlePartLength;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user