WOW!
Alan Bateman was kind enough to send me a test program for the NIO.2
in Java 7 (see below). I downloaded the current JDK7 binaries and
tested on my system. The results are very impressive. On my first
test, file walking over the network was actually faster than on the
local machine! In subsequent repeats of the test, the local machine
was faster - due to local caching I presume. In any event it looks
like this problem has been solved for Java7 ;-)
Thank you Alan!
John
12:00 c:\temp
java TstJava7NIO c:\c <--- local
Found 4720 directories and 29622 files in 49688 ms
12:01 c:\temp
java TstJava7NIO j:\c <--- network
Found 5390 directories and 34197 files in 25812 ms
12:02 c:\temp
java TstJava7NIO c:\c
Found 4720 directories and 29622 files in 1515 ms
12:02 c:\temp
java TstJava7NIO j:\c
Found 5390 directories and 34197 files in 12937 ms
12:03 c:\temp
java TstJava7NIO c:\c
Found 4720 directories and 29622 files in 1516 ms
12:03 c:\temp
java TstJava7NIO j:\c
Found 5390 directories and 34197 files in 12843 ms
Alan's test program:
import java.nio.file.*;
import java.nio.file.attribute.*;
public class TstJava7NIO {
static class Counter extends SimpleFileVisitor<Path> {
private int dirCount;
private int fileCount;
int dirCount() {
return dirCount;
}
int fileCount() {
return fileCount;
}
@Override
public FileVisitResult preVisitDirectory(Path dir) {
dirCount++;
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) {
fileCount++;
return FileVisitResult.CONTINUE;
}
}
public static void main(String[] args) {
Path top = FileSystems.getDefault().getPath(args[0]);
Counter counter = new Counter();
long start = System.currentTimeMillis();
Files.walkFileTree(top, counter);
long end = System.currentTimeMillis();
System.out.format("Found %d directories and %d files in %d ms
%n", counter.dirCount(), counter.fileCount,
(end - start));
}
}
--
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.