Added another baseline benchmark against StringUtils.split() from commons-lang
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1658392 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
64f454e3ef
commit
78e2b24633
6
pom.xml
6
pom.xml
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
@ -62,6 +63,21 @@ public class CSVBenchmark {
|
|||
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;
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public int parseCommonsCSV(Blackhole bh) throws Exception {
|
||||
BufferedReader in = getReader();
|
||||
|
|
Loading…
Reference in New Issue