Skip to content

Commit d992442

Browse files
committed
Use locally stored big file as per perf/PerformanceTest
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1397851 13f79535-47bb-0310-9956-ffa450edef68
1 parent 992c064 commit d992442

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/test/java/org/apache/commons/csv/PerformanceTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@
1818
package org.apache.commons.csv;
1919

2020
import java.io.BufferedReader;
21+
import java.io.File;
22+
import java.io.FileInputStream;
23+
import java.io.FileOutputStream;
2124
import java.io.FileReader;
2225
import java.io.IOException;
26+
import java.io.InputStream;
27+
import java.io.OutputStream;
2328
import java.lang.reflect.Constructor;
29+
import java.util.zip.GZIPInputStream;
30+
31+
import org.apache.commons.io.IOUtils;
2432

2533
/**
2634
* Basic test harness.
@@ -57,7 +65,18 @@ public class PerformanceTest {
5765

5866
private static final CSVFormat format = CSVFormat.EXCEL;
5967

68+
private static final File BIG_FILE = new File(System.getProperty("java.io.tmpdir"), "worldcitiespop.txt");
69+
6070
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+
}
6180
final int argc = args.length;
6281
String tests[];
6382
if (argc > 0) {
@@ -100,7 +119,7 @@ public static void main(final String [] args) throws Exception {
100119
}
101120

102121
private static BufferedReader getReader() throws IOException {
103-
return new BufferedReader(new FileReader("worldcitiespop.txt"));
122+
return new BufferedReader(new FileReader(BIG_FILE));
104123
}
105124

106125
// Container for basic statistics

0 commit comments

Comments
 (0)