commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1397851 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java
Date Sat, 13 Oct 2012 15:15:37 GMT
Author: sebb
Date: Sat Oct 13 15:15:36 2012
New Revision: 1397851

URL: http://svn.apache.org/viewvc?rev=1397851&view=rev
Log:
Use locally stored big file as per perf/PerformanceTest

Modified:
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java?rev=1397851&r1=1397850&r2=1397851&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java Sat
Oct 13 15:15:36 2012
@@ -18,9 +18,17 @@
 package org.apache.commons.csv;
 
 import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Constructor;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.commons.io.IOUtils;
 
 /**
  * Basic test harness.
@@ -57,7 +65,18 @@ public class PerformanceTest {
 
     private static final CSVFormat format = CSVFormat.EXCEL;
 
+    private static final File BIG_FILE = new File(System.getProperty("java.io.tmpdir"), "worldcitiespop.txt");
+
     public static void main(final String [] args) throws Exception {
+        if (BIG_FILE.exists()) {
+            System.out.println(String.format("Found test fixture %s: %,d bytes.", BIG_FILE,
BIG_FILE.length()));
+        } else {
+            System.out.println("Decompressing test fixture " + BIG_FILE + "...");
+            final InputStream input = new GZIPInputStream(new FileInputStream("src/test/resources/perf/worldcitiespop.txt.gz"));
+            final OutputStream output = new FileOutputStream(BIG_FILE);
+            IOUtils.copy(input, output);
+            System.out.println(String.format("Decompressed test fixture %s: %,d bytes.",
BIG_FILE, BIG_FILE.length()));            
+        }
         final int argc = args.length;
         String tests[];
         if (argc > 0) {
@@ -100,7 +119,7 @@ public class PerformanceTest {
     }
 
     private static BufferedReader getReader() throws IOException {
-        return new BufferedReader(new FileReader("worldcitiespop.txt"));
+        return new BufferedReader(new FileReader(BIG_FILE));
     }
 
     // Container for basic statistics



Mime
View raw message