@@ -39,20 +39,15 @@ private static long runFastFileIndex(String path, boolean warmup) {
3939 if (!warmup ) System .out .print ("FastFileIndex: " );
4040
4141 long start = System .currentTimeMillis ();
42- AtomicLong count = new AtomicLong (0 );
4342
44- FastFileIndex .buildWithProgress (new String []{path }, new ProgressCallback () {
45- @ Override
46- public void onProgress (String currentFile , long totalFiles , long currentPath ) {
47- count .incrementAndGet ();
48- }
49- });
43+ FastFileIndex .build (new String []{path });
5044
5145 long end = System .currentTimeMillis ();
5246 long elapsed = end - start ;
5347
5448 if (!warmup ) {
55- System .out .println (elapsed + " ms (" + count .get () + " files)" );
49+ long count = FastFileIndex .getEntryCount ();
50+ System .out .println (elapsed + " ms (" + count + " files)" );
5651 }
5752
5853 return elapsed ;
@@ -65,9 +60,20 @@ private static long runJavaWalk(String path, boolean warmup) {
6560 AtomicLong count = new AtomicLong (0 );
6661
6762 try {
68- Files .walk (Paths .get (path ))
69- .filter (Files ::isRegularFile )
70- .forEach (file -> count .incrementAndGet ());
63+ Files .walkFileTree (Paths .get (path ), new SimpleFileVisitor <Path >() {
64+ @ Override
65+ public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) {
66+ if (attrs .isRegularFile ()) {
67+ count .incrementAndGet ();
68+ }
69+ return FileVisitResult .CONTINUE ;
70+ }
71+
72+ @ Override
73+ public FileVisitResult visitFileFailed (Path file , IOException exc ) {
74+ return FileVisitResult .CONTINUE ;
75+ }
76+ });
7177 } catch (IOException e ) {
7278 System .err .println ("Error: " + e .getMessage ());
7379 }
0 commit comments