You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2015/02/09 13:58:44 UTC
svn commit: r1658392 - in /commons/proper/csv/trunk: pom.xml
src/test/java/org/apache/commons/csv/CSVBenchmark.java
Author: ebourg
Date: Mon Feb 9 12:58:44 2015
New Revision: 1658392
URL: http://svn.apache.org/r1658392
Log:
Added another baseline benchmark against StringUtils.split() from commons-lang
Modified:
commons/proper/csv/trunk/pom.xml
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java
Modified: commons/proper/csv/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/pom.xml?rev=1658392&r1=1658391&r2=1658392&view=diff
==============================================================================
--- commons/proper/csv/trunk/pom.xml (original)
+++ commons/proper/csv/trunk/pom.xml Mon Feb 9 12:58:44 2015
@@ -431,6 +431,12 @@ CSV files of various types.
<scope>system</scope>
<systemPath>${basedir}/csv-1.0.jar</systemPath>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.2.1</version>
+ </dependency>
</dependencies>
<properties>
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java?rev=1658392&r1=1658391&r2=1658392&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java Mon Feb 9 12:58:44 2015
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import com.generationjava.io.CsvReader;
+import org.apache.commons.lang3.StringUtils;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@@ -39,8 +40,8 @@ import org.supercsv.prefs.CsvPreference;
@BenchmarkMode(Mode.AverageTime)
@Fork(value = 1, jvmArgs = "-server")
@Threads(1)
-@Warmup(iterations = 10)
-@Measurement(iterations = 10)
+@Warmup(iterations = 5)
+@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class CSVBenchmark {
@@ -49,7 +50,7 @@ public class CSVBenchmark {
}
@Benchmark
- public int baseline(Blackhole bh) throws Exception {
+ public int read(Blackhole bh) throws Exception {
BufferedReader in = getReader();
int count = 0;
String line;
@@ -58,6 +59,21 @@ public class CSVBenchmark {
}
bh.consume(count);
+ in.close();
+ return count;
+ }
+
+ @Benchmark
+ public int split(Blackhole bh) throws Exception {
+ BufferedReader in = getReader();
+ int count = 0;
+ String line;
+ while ((line = in.readLine()) != null) {
+ String[] values = StringUtils.split(line, ',');
+ count += values.length;
+ }
+
+ bh.consume(count);
in.close();
return count;
}