Reading the file attributes is very slow compared to Windows and Linux.
In my example I add the size of all files in a specific directory. The directory contains 30.000 files with 32KB. On Windows it runs 135 ms and on AS400 1050 ms. That is 10x faster!
Other methods like File.listFiles() on AS400 are faster than Windows, but they still take 1000+ ms. Also tested IFSFile.listFiles() and SQL IFS access. So it would be nice if only accessing the file attributes would be faster.
# example: calculate file size in directory
private long walkWithJava7(String dirPath) throws IOException
{
AtomicLong size = new AtomicLong(0);
Path folder = Paths.get(dirPath);
Files.walkFileTree(folder, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
{
//Use attributes - creating File object is slow!
if(attrs.isRegularFile()) {
size.addAndGet(attrs.size());
}
return FileVisitResult.CONTINUE;
}
});
return size.longValue();
}
Reading the file attributes is very slow compared to Windows and Linux. In my example I add the size of all files in a specific directory. The directory contains 30.000 files with 32KB. On Windows it runs 135 ms and on AS400 1050 ms. That is 10x faster!
Other methods like File.listFiles() on AS400 are faster than Windows, but they still take 1000+ ms. Also tested IFSFile.listFiles() and SQL IFS access. So it would be nice if only accessing the file attributes would be faster.