aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Kliuchnikov <eustas@google.com>2023-07-28 01:06:17 -0700
committerCopybara-Service <copybara-worker@google.com>2023-07-28 01:06:50 -0700
commit0300be36ba019c55d2edc48353270fa18008d49c (patch)
tree9f1eed20ce14b803bd6946bf413ae4d04f6c8aac
parent4fc753e707c141328ee707bc2df23603391d0102 (diff)
downloadbrotli-0300be36ba019c55d2edc48353270fa18008d49c.zip
brotli-0300be36ba019c55d2edc48353270fa18008d49c.tar.gz
brotli-0300be36ba019c55d2edc48353270fa18008d49c.tar.bz2
add "repeat" to Java toy decoder
PiperOrigin-RevId: 551770992
-rw-r--r--java/org/brotli/dec/Decoder.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/java/org/brotli/dec/Decoder.java b/java/org/brotli/dec/Decoder.java
index 599588e..e33f5a9 100644
--- a/java/org/brotli/dec/Decoder.java
+++ b/java/org/brotli/dec/Decoder.java
@@ -24,21 +24,15 @@ public class Decoder {
return totalOut;
}
- public static void main(String... args) throws IOException {
- if (args.length != 2) {
- System.out.println("Usage: decoder <compressed_in> <decompressed_out>");
- return;
- }
-
- byte[] buffer = new byte[1024 * 1024];
+ private static void decompress(String fromPath, String toPath, byte[] buffer) throws IOException {
long start;
long bytesDecoded;
long end;
InputStream in = null;
OutputStream out = null;
try {
- in = new FileInputStream(args[0]);
- out = new FileOutputStream(args[1]);
+ in = new FileInputStream(fromPath);
+ out = new FileOutputStream(toPath);
start = System.nanoTime();
bytesDecoded = decodeBytes(in, out, buffer);
end = System.nanoTime();
@@ -58,4 +52,21 @@ public class Decoder {
double mbDecoded = bytesDecoded / (1024.0 * 1024.0);
System.out.println(mbDecoded / timeDelta + " MiB/s");
}
+
+ public static void main(String... args) throws IOException {
+ if (args.length != 2 && args.length != 3) {
+ System.out.println("Usage: decoder <compressed_in> <decompressed_out> [repeat]");
+ return;
+ }
+
+ int repeat = 1;
+ if (args.length == 3) {
+ repeat = Integer.parseInt(args[2]);
+ }
+
+ byte[] buffer = new byte[1024 * 1024];
+ for (int i = 0; i < repeat; ++i) {
+ decompress(args[0], args[1], buffer);
+ }
+ }
}