mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
testCOWListPerformanceAdd: test addition instead of iteration
This commit is contained in:
+9
-10
@@ -19,7 +19,6 @@ package com.intellij.util.containers;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -228,19 +227,19 @@ public class ContainerUtilTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testCOWListPerformanceAdd() {
|
||||
PlatformTestUtil.startPerformanceTest("COWList add", 3000, new ThrowableRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
List<Object> my = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
long start = System.currentTimeMillis();
|
||||
List<Object> my = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
PlatformTestUtil.startPerformanceTest("COWList add", 3000, () -> {
|
||||
List<Object> local = my;
|
||||
for (int it=0; it<10; it++) {
|
||||
local.clear();
|
||||
for (int i = 0; i < 15000; i++) {
|
||||
my.add(i);
|
||||
assertEquals(i, my.indexOf(i));
|
||||
local.add(i);
|
||||
}
|
||||
long elapsed = System.currentTimeMillis() - start;
|
||||
System.out.println("elapsed = " + elapsed);
|
||||
}
|
||||
}).useLegacyScaling().assertTiming();
|
||||
for (int i = 0; i < my.size(); i++) {
|
||||
assertEquals(i, my.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertReallyEmpty(List<Object> my) {
|
||||
|
||||
Reference in New Issue
Block a user