diff --git a/bin/checkDataIntegrity/Args.class b/bin/checkDataIntegrity/Args.class index 5a2fc18..bb6709d 100644 Binary files a/bin/checkDataIntegrity/Args.class and b/bin/checkDataIntegrity/Args.class differ diff --git a/bin/checkDataIntegrity/BufferPool.class b/bin/checkDataIntegrity/BufferPool.class index 444dc5c..2b15b54 100644 Binary files a/bin/checkDataIntegrity/BufferPool.class and b/bin/checkDataIntegrity/BufferPool.class differ diff --git a/bin/checkDataIntegrity/Main$1.class b/bin/checkDataIntegrity/Main$1.class index fa4361b..839309c 100644 Binary files a/bin/checkDataIntegrity/Main$1.class and b/bin/checkDataIntegrity/Main$1.class differ diff --git a/bin/checkDataIntegrity/Main.class b/bin/checkDataIntegrity/Main.class index 99724f1..edd00b2 100644 Binary files a/bin/checkDataIntegrity/Main.class and b/bin/checkDataIntegrity/Main.class differ diff --git a/checkDataIntegrity.jar b/checkDataIntegrity.jar index 36619df..a425292 100644 Binary files a/checkDataIntegrity.jar and b/checkDataIntegrity.jar differ diff --git a/src/checkDataIntegrity/Args.java b/src/checkDataIntegrity/Args.java index 2ca1246..50ef9ef 100644 --- a/src/checkDataIntegrity/Args.java +++ b/src/checkDataIntegrity/Args.java @@ -1,6 +1,6 @@ package checkDataIntegrity; -record Args(String path0, String path1, int skip, int timeLimit) { +record Args(String path0, String path1, int threads, int skip, int timeLimit) { } diff --git a/src/checkDataIntegrity/BufferPool.java b/src/checkDataIntegrity/BufferPool.java index c9bf12e..5b5a3ae 100644 --- a/src/checkDataIntegrity/BufferPool.java +++ b/src/checkDataIntegrity/BufferPool.java @@ -9,7 +9,7 @@ class BufferPool { static byte[] get() { byte[] buf = queue.poll(); if (buf == null) { - buf = new byte[16384]; + buf = new byte[4096]; } return buf; } diff --git a/src/checkDataIntegrity/Main.java b/src/checkDataIntegrity/Main.java index 2aec56a..f1e31c3 100644 --- a/src/checkDataIntegrity/Main.java +++ b/src/checkDataIntegrity/Main.java @@ -18,9 +18,46 @@ public class Main { } final ProgramState state = new ProgramState(System.currentTimeMillis(), new AtomicLong(), new AtomicLong(), new AtomicLong()); + final WorkerPool workerPool = new WorkerPool(parsedArgs, state, parsedArgs.threads()); - final WorkerPool workerPool = new WorkerPool(parsedArgs, state, 32); + walk(parsedArgs, state, workerPool); + workerPool.awaitEmpty(); + workerPool.interrupt(); + workerPool.join(); + + printStats(state); + + System.exit(state.countErr().get() > 0 ? 1 : 0); + } + + private static Args parseArgs(final String[] args) { + if (args.length < 4) { + System.err.println("Usage: checkDataIntegrity.java "); + return null; + } + + final Args result = new Args( + args[0], + args[1], + Integer.parseInt(args[2]), + Integer.parseInt(args[3]), + Integer.parseInt(args[4])); + System.out.println(result); + return result; + } + + private static void printStats(final ProgramState state) { + final Duration duration = Duration.ofMillis(System.currentTimeMillis() - state.start()); + System.out.println("Took: " + duration.toString()); + System.out.println("Files checked: " + state.count().get()); + if (duration.toSeconds() > 0) { + System.out.println("Throughput: " + (state.bytes().get() / duration.toSeconds() / 1024 / 1024) + " Mib/s"); + } + System.out.println("Errors: " + state.countErr().get()); + } + + private static void walk(final Args parsedArgs, final ProgramState state, final WorkerPool workerPool) throws IOException { final AtomicLong walkTreeCounter = new AtomicLong(); Files.walkFileTree(Path.of(parsedArgs.path0()), new FileVisitor<>() { @@ -57,39 +94,5 @@ public class Main { return FileVisitResult.CONTINUE; } }); - - workerPool.awaitEmpty(); - workerPool.interrupt(); - workerPool.join(); - - printStats(state); - - System.exit(state.countErr().get() > 0 ? 1 : 0); } - - private static Args parseArgs(final String[] args) { - if (args.length < 4) { - System.err.println("Usage: checkDataIntegrity.java "); - return null; - } - - final Args result = new Args( - args[0], - args[1], - Integer.parseInt(args[2]), - Integer.parseInt(args[3])); - System.out.println(result); - return result; - } - - private static void printStats(final ProgramState state) { - final Duration duration = Duration.ofMillis(System.currentTimeMillis() - state.start()); - System.out.println("Took: " + duration.toString()); - System.out.println("Files checked: " + state.count().get()); - if (duration.toSeconds() > 0) { - System.out.println("Throughput: " + (state.bytes().get() / duration.toSeconds() / 1024 / 1024) + " Mib/s"); - } - System.out.println("Errors: " + state.countErr().get()); - } - }