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 0453989 CSV-286: Cleanup and Document Performance Test Harness (#170)
0453989 is described below
commit 0453989efe8629ecb5a2839da056b4ccc3451b18
Author: belugabehr <[email protected]>
AuthorDate: Mon Jul 19 16:39:29 2021 -0400
CSV-286: Cleanup and Document Performance Test Harness (#170)
---
BENCHMARK.md | 5 +++++
.../org/apache/commons/csv/PerformanceTest.java | 21 ++++++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/BENCHMARK.md b/BENCHMARK.md
index 67569ea..e8b579b 100644
--- a/BENCHMARK.md
+++ b/BENCHMARK.md
@@ -72,3 +72,8 @@ mvn test -Dtest=PerformanceTest
```
> :warning: This performance test does not use JMH; it uses simple timing
> metrics.
+
+Performance Test Harness
+-------------
+
+CSV offers a secondary performance test harness located at:
`org.apache.commons.csv.PerformanceTest`
diff --git a/src/test/java/org/apache/commons/csv/PerformanceTest.java
b/src/test/java/org/apache/commons/csv/PerformanceTest.java
index a9dcca0..84ed083 100644
--- a/src/test/java/org/apache/commons/csv/PerformanceTest.java
+++ b/src/test/java/org/apache/commons/csv/PerformanceTest.java
@@ -37,8 +37,6 @@ import org.apache.commons.io.IOUtils;
/**
* Basic test harness.
- *
- * Requires test file to be downloaded separately.
*/
@SuppressWarnings("boxing")
public class PerformanceTest {
@@ -68,20 +66,21 @@ public class PerformanceTest {
private static final CSVFormat format = CSVFormat.EXCEL;
- private static final File BIG_FILE = new
File("src/test/resources/perf/worldcitiespop.txt");
+ 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");
public static void main(final String [] args) throws Exception {
if (BIG_FILE.exists()) {
System.out.printf("Found test fixture %s: %,d bytes.%n", BIG_FILE,
BIG_FILE.length());
} else {
- final File compressedFile = new File(BIG_FILE.getParentFile(),
BIG_FILE.getName() + ".gz");
- System.out.printf("Decompressing test fixture %s...%n",
compressedFile);
- long bytesOut = 0L;
- try (final InputStream input = new GZIPInputStream(new
FileInputStream(compressedFile));
- final OutputStream output = new
FileOutputStream(BIG_FILE)) {
- bytesOut = IOUtils.copy(input, output);
- }
- System.out.printf("Decompressed test fixture %s: %,d bytes to: %s:
%,d bytes.%n", compressedFile, compressedFile.length(), BIG_FILE, bytesOut);
+ System.out.println("Decompressing test fixture to: " + BIG_FILE +
"...");
+ try (
+ final InputStream input = new GZIPInputStream(
+
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()));
+ }
}
final int argc = args.length;
if (argc > 0) {