CSV-284: Formalize PerformanceTest (#168)

* CSV-284: Formalize PerformanceTest

* Revert some changes
This commit is contained in:
belugabehr 2021-07-15 09:03:51 -04:00 committed by GitHub
parent a2ba9b5288
commit 47479b6305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -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.

View File

@ -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()));