Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BENCHMARK.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
21 changes: 10 additions & 11 deletions src/test/java/org/apache/commons/csv/PerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

/**
* Basic test harness.
*
* Requires test file to be downloaded separately.
*/
@SuppressWarnings("boxing")
public class PerformanceTest {
Expand Down Expand Up @@ -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) {
Expand Down