From 47479b630527b7f5b8edc15e8ddda79020761a39 Mon Sep 17 00:00:00 2001 From: belugabehr <12578579+belugabehr@users.noreply.github.com> Date: Thu, 15 Jul 2021 09:03:51 -0400 Subject: [PATCH] CSV-284: Formalize PerformanceTest (#168) * CSV-284: Formalize PerformanceTest * Revert some changes --- BENCHMARK.md | 12 ++++++++++++ .../org/apache/commons/csv/perf/PerformanceTest.java | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/BENCHMARK.md b/BENCHMARK.md index ad36a4c8..67569ead 100644 --- a/BENCHMARK.md +++ b/BENCHMARK.md @@ -60,3 +60,15 @@ mvn test -Pbenchmark -Dbenchmark= # 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 90c549b7..0579dd12 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()));