This commit is contained in:
Alexey Kudravtsev
2011-01-28 14:18:46 +03:00
parent 038618689d
commit ccdc8ec29d
3 changed files with 39 additions and 43 deletions
@@ -1,8 +1,7 @@
package com.intellij.openapi.vfs;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import java.io.File;
import java.io.IOException;
@@ -10,33 +9,28 @@ import java.io.IOException;
public class GetPathPerformanceTest extends IdeaTestCase {
public void testGetPath() throws IOException {
File dir = createTempDirectory();
try {
File subdir1 = new File(dir, "1");
File subdir2 = new File(dir, "2");
subdir1.mkdir();
subdir2.mkdir();
for (int i = 0; i < 10; ++i) {
new File(subdir1, "" + i).createNewFile();
new File(subdir2, "" + i).createNewFile();
}
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/'));
assertNotNull(file);
File subdir1 = new File(dir, "1");
File subdir2 = new File(dir, "2");
subdir1.mkdir();
subdir2.mkdir();
for (int i = 0; i < 10; ++i) {
new File(subdir1, "" + i).createNewFile();
new File(subdir2, "" + i).createNewFile();
}
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/'));
assertNotNull(file);
final VirtualFile[] children = file.getChildren();
Runnable runnable = new Runnable() {
@Override
public void run() {
for( int i = 0; i < 1000000; ++i ) {
for( VirtualFile child: children) {
child.getPath();
}
final VirtualFile[] children = file.getChildren();
Runnable runnable = new Runnable() {
@Override
public void run() {
for( int i = 0; i < 1000000; ++i ) {
for( VirtualFile child: children) {
child.getPath();
}
}
};
IdeaTestUtil.assertTiming("Performance failed", 3000, runnable);
}
finally {
FileUtil.delete(dir);
}
}
};
PlatformTestUtil.assertTiming("Performance failed", 3000, runnable);
}
}