Skip to content

Commit 47479b6

Browse files
authored
CSV-284: Formalize PerformanceTest (apache#168)
* CSV-284: Formalize PerformanceTest * Revert some changes
1 parent a2ba9b5 commit 47479b6

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

BENCHMARK.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,15 @@ mvn test -Pbenchmark -Dbenchmark=<name>
6060
# Example of running basic "read" benchmark
6161
mvn test -Pbenchmark -Dbenchmark=read
6262
```
63+
64+
Performance Test
65+
-------------
66+
67+
Apache Commons CSV includes a stand-alone performance test which only covers commons-csv.
68+
69+
```shell
70+
# Run the performance test
71+
mvn test -Dtest=PerformanceTest
72+
```
73+
74+
> :warning: This performance test does not use JMH; it uses simple timing metrics.

src/test/java/org/apache/commons/csv/perf/PerformanceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.io.BufferedReader;
2121
import java.io.File;
22-
import java.io.FileInputStream;
2322
import java.io.FileNotFoundException;
2423
import java.io.FileOutputStream;
2524
import java.io.FileReader;
@@ -46,6 +45,7 @@ public class PerformanceTest {
4645

4746
private final int max = 10;
4847

48+
private static final String TEST_RESRC = "org/apache/commons/csv/perf/worldcitiespop.txt.gz";
4949
private static final File BIG_FILE = new File(System.getProperty("java.io.tmpdir"), "worldcitiespop.txt");
5050

5151
@BeforeAll
@@ -54,10 +54,10 @@ public static void setUpClass() throws FileNotFoundException, IOException {
5454
System.out.println(String.format("Found test fixture %s: %,d bytes.", BIG_FILE, BIG_FILE.length()));
5555
return;
5656
}
57-
System.out.println("Decompressing test fixture " + BIG_FILE + "...");
57+
System.out.println("Decompressing test fixture to: " + BIG_FILE + "...");
5858
try (
5959
final InputStream input = new GZIPInputStream(
60-
new FileInputStream("src/test/resources/perf/worldcitiespop.txt.gz"));
60+
PerformanceTest.class.getClassLoader().getResourceAsStream(TEST_RESRC));
6161
final OutputStream output = new FileOutputStream(BIG_FILE)) {
6262
IOUtils.copy(input, output);
6363
System.out.println(String.format("Decompressed test fixture %s: %,d bytes.", BIG_FILE, BIG_FILE.length()));

0 commit comments

Comments
 (0)