This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git


The following commit(s) were added to refs/heads/master by this push:
     new 47479b6  CSV-284: Formalize PerformanceTest (#168)
47479b6 is described below

commit 47479b630527b7f5b8edc15e8ddda79020761a39
Author: belugabehr <12578579+belugab...@users.noreply.github.com>
AuthorDate: Thu Jul 15 09:03:51 2021 -0400

    CSV-284: Formalize PerformanceTest (#168)
    
    * CSV-284: Formalize PerformanceTest
    
    * Revert some changes
---
 BENCHMARK.md                                                 | 12 ++++++++++++
 .../java/org/apache/commons/csv/perf/PerformanceTest.java    |  6 +++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/BENCHMARK.md b/BENCHMARK.md
index ad36a4c..67569ea 100644
--- a/BENCHMARK.md
+++ b/BENCHMARK.md
@@ -60,3 +60,15 @@ mvn test -Pbenchmark -Dbenchmark=<name>
 # Example of running basic "read" benchmark
 mvn test -Pbenchmark -Dbenchmark=read
 ```
+
+Performance Test
+-------------
+
+Apache Commons CSV includes a stand-alone performance test which only covers 
commons-csv.
+
+```shell
+# Run the performance test
+mvn test -Dtest=PerformanceTest
+```
+
+> :warning: This performance test does not use JMH; it uses simple timing 
metrics.
diff --git a/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java 
b/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java
index 90c549b..0579dd1 100644
--- a/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java
+++ b/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java
@@ -19,7 +19,6 @@ package org.apache.commons.csv.perf;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileReader;
@@ -46,6 +45,7 @@ public class PerformanceTest {
 
     private final int max = 10;
 
+    private static final String TEST_RESRC = 
"org/apache/commons/csv/perf/worldcitiespop.txt.gz";
     private static final File BIG_FILE = new 
File(System.getProperty("java.io.tmpdir"), "worldcitiespop.txt");
 
     @BeforeAll
@@ -54,10 +54,10 @@ public class PerformanceTest {
             System.out.println(String.format("Found test fixture %s: %,d 
bytes.", BIG_FILE, BIG_FILE.length()));
             return;
         }
-        System.out.println("Decompressing test fixture " + BIG_FILE + "...");
+        System.out.println("Decompressing test fixture to: " + BIG_FILE + 
"...");
         try (
             final InputStream input = new GZIPInputStream(
-                new 
FileInputStream("src/test/resources/perf/worldcitiespop.txt.gz"));
+                
PerformanceTest.class.getClassLoader().getResourceAsStream(TEST_RESRC));
             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()));

Reply via email to