Can anybody explain what’s going on with my iteration of a list of FileStores?
I’ve got a Runnable task that’s executing once a second and calls this code:
private ArrayList<FileStore> getFileStores() {
Iterable<FileStore> stores;
try {
stores = app.fileSystem.getFileStores();
} catch (Exception ex) {
return null;
}
ArrayList<FileStore> newstores = new ArrayList<>();
long start = System.currentTimeMillis();
if (stores != null) {
Iterator<FileStore> iter = stores.iterator();
while (iter.hasNext()) {
newstores.add(iter.next());
}
}
System.out.println("<<<<<<<< FILESTORE update in " + toElapsed(start));
return newstores;
}
And here’s the output:
<<<<<<<< FILESTORE update in 1 ms.
<<<<<<<< FILESTORE update in 144 ms.
<<<<<<<< FILESTORE update in 1 ms.
<<<<<<<< FILESTORE update in 2 ms.
<<<<<<<< FILESTORE update in 147 ms.
<<<<<<<< FILESTORE update in 2 ms.
<<<<<<<< FILESTORE update in 2 ms.
<<<<<<<< FILESTORE update in 165 ms.
<<<<<<<< FILESTORE update in 4 ms.
<<<<<<<< FILESTORE update in 134 ms.
<<<<<<<< FILESTORE update in 138 ms.
<<<<<<<< FILESTORE update in 1 ms.
<<<<<<<< FILESTORE update in 2 ms.
Why such a big difference in performance on each pass?
3