Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A3A70D6EE for ; Fri, 12 Oct 2012 13:31:56 +0000 (UTC) Received: (qmail 38217 invoked by uid 500); 12 Oct 2012 13:31:56 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 37908 invoked by uid 500); 12 Oct 2012 13:31:52 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 37876 invoked by uid 99); 12 Oct 2012 13:31:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2012 13:31:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2012 13:31:49 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BDD3B23889D5 for ; Fri, 12 Oct 2012 13:31:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1397559 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java Date: Fri, 12 Oct 2012 13:31:06 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121012133106.BDD3B23889D5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Fri Oct 12 13:31:06 2012 New Revision: 1397559 URL: http://svn.apache.org/viewvc?rev=1397559&view=rev Log: Allow performance test to traverse column values (optional). Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java?rev=1397559&r1=1397558&r2=1397559&view=diff ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java (original) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java Fri Oct 12 13:31:06 2012 @@ -30,6 +30,7 @@ import java.io.Reader; import java.util.zip.GZIPInputStream; import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVRecord; import org.apache.commons.io.IOUtils; import org.junit.BeforeClass; import org.junit.Ignore; @@ -64,13 +65,18 @@ public class PerformanceTest { return new BufferedReader(new FileReader(BIG_FILE)); } - private long parse(final Reader in) throws IOException { + private long parse(final Reader in, boolean traverseColumns) throws IOException { final CSVFormat format = CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(false); - long count = 0; - for (final Object record : format.parse(in)) { - count++; + long recordCount = 0; + for (final CSVRecord record : format.parse(in)) { + recordCount++; + if (traverseColumns) { + for (String value : record) { + // do nothing for now + } + } } - return count; + return recordCount; } private void println() { @@ -89,9 +95,9 @@ public class PerformanceTest { return count; } - public long testParseBigFile() throws Exception { + public long testParseBigFile(boolean traverseColumns) throws Exception { final long startMillis = System.currentTimeMillis(); - final long count = this.parse(this.getBufferedReader()); + final long count = this.parse(this.getBufferedReader(), traverseColumns); final long totalMillis = System.currentTimeMillis() - startMillis; this.println(String.format("File parsed in %,d milliseconds with Commons CSV: %,d lines.", totalMillis, count)); return totalMillis; @@ -101,7 +107,7 @@ public class PerformanceTest { public void testParseBigFileRepeat() throws Exception { long bestTime = Long.MAX_VALUE; for (int i = 0; i < this.max; i++) { - bestTime = Math.min(this.testParseBigFile(), bestTime); + bestTime = Math.min(this.testParseBigFile(false), bestTime); } this.println(String.format("Best time out of %,d is %,d milliseconds.", this.max, bestTime)); }