|
18 | 18 | package org.apache.commons.csv; |
19 | 19 |
|
20 | 20 | import java.io.BufferedReader; |
| 21 | +import java.io.File; |
| 22 | +import java.io.FileInputStream; |
| 23 | +import java.io.FileOutputStream; |
21 | 24 | import java.io.FileReader; |
22 | 25 | import java.io.IOException; |
| 26 | +import java.io.InputStream; |
| 27 | +import java.io.OutputStream; |
23 | 28 | import java.lang.reflect.Constructor; |
| 29 | +import java.util.zip.GZIPInputStream; |
| 30 | + |
| 31 | +import org.apache.commons.io.IOUtils; |
24 | 32 |
|
25 | 33 | /** |
26 | 34 | * Basic test harness. |
@@ -57,7 +65,18 @@ public class PerformanceTest { |
57 | 65 |
|
58 | 66 | private static final CSVFormat format = CSVFormat.EXCEL; |
59 | 67 |
|
| 68 | + private static final File BIG_FILE = new File(System.getProperty("java.io.tmpdir"), "worldcitiespop.txt"); |
| 69 | + |
60 | 70 | public static void main(final String [] args) throws Exception { |
| 71 | + if (BIG_FILE.exists()) { |
| 72 | + System.out.println(String.format("Found test fixture %s: %,d bytes.", BIG_FILE, BIG_FILE.length())); |
| 73 | + } else { |
| 74 | + System.out.println("Decompressing test fixture " + BIG_FILE + "..."); |
| 75 | + final InputStream input = new GZIPInputStream(new FileInputStream("src/test/resources/perf/worldcitiespop.txt.gz")); |
| 76 | + final OutputStream output = new FileOutputStream(BIG_FILE); |
| 77 | + IOUtils.copy(input, output); |
| 78 | + System.out.println(String.format("Decompressed test fixture %s: %,d bytes.", BIG_FILE, BIG_FILE.length())); |
| 79 | + } |
61 | 80 | final int argc = args.length; |
62 | 81 | String tests[]; |
63 | 82 | if (argc > 0) { |
@@ -100,7 +119,7 @@ public static void main(final String [] args) throws Exception { |
100 | 119 | } |
101 | 120 |
|
102 | 121 | private static BufferedReader getReader() throws IOException { |
103 | | - return new BufferedReader(new FileReader("worldcitiespop.txt")); |
| 122 | + return new BufferedReader(new FileReader(BIG_FILE)); |
104 | 123 | } |
105 | 124 |
|
106 | 125 | // Container for basic statistics |
|
0 commit comments