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 10E15DA92 for ; Tue, 11 Sep 2012 18:19:02 +0000 (UTC) Received: (qmail 38456 invoked by uid 500); 11 Sep 2012 18:19:01 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 38411 invoked by uid 500); 11 Sep 2012 18:19:01 -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 38395 invoked by uid 99); 11 Sep 2012 18:19:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2012 18:19:01 +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; Tue, 11 Sep 2012 18:18:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 196F423888E3 for ; Tue, 11 Sep 2012 18:18:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1383504 - in /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf: ./ PerformanceTest.java Date: Tue, 11 Sep 2012 18:18:15 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120911181815.196F423888E3@eris.apache.org> Author: ggregory Date: Tue Sep 11 18:18:14 2012 New Revision: 1383504 URL: http://svn.apache.org/viewvc?rev=1383504&view=rev Log: Fix compilation issue. Added: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java (with props) Added: 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=1383504&view=auto ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java (added) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java Tue Sep 11 18:18:14 2012 @@ -0,0 +1,81 @@ +package org.apache.commons.csv.perf; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; + +import org.apache.commons.csv.CSVFormat; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Tests performance. + * + * Only enable for your own development. + */ +public class PerformanceTest { + + private final int max = 10; + + private BufferedReader getBufferedReader() throws IOException { + return new BufferedReader(new FileReader("src/test/resources/worldcitiespop.txt")); + } + + private long parse(Reader in) throws IOException { + CSVFormat format = CSVFormat.DEFAULT.withSurroundingSpacesIgnored(false); + long count = 0; + for (Object record : format.parse(in)) { + count++; + } + return count; + } + + private void println() { + System.out.println(); + } + + private void println(String s) { + System.out.println(s); + } + + private long readAll(BufferedReader in) throws IOException { + long count = 0; + while (in.readLine() != null) { + count++; + } + return count; + } + + @Test + @Ignore + public void testParseBigFile() throws Exception { + long t0 = System.currentTimeMillis(); + long count = this.parse(this.getBufferedReader()); + this.println("File parsed in " + (System.currentTimeMillis() - t0) + "ms with Commons CSV" + " " + count + + " lines"); + this.println(); + } + + @Test + @Ignore + public void testParseBigFileRepeat() throws Exception { + for (int i = 0; i < this.max; i++) { + this.testParseBigFile(); + } + this.println(); + } + + @Test + @Ignore + public void testReadBigFile() throws Exception { + for (int i = 0; i < this.max; i++) { + BufferedReader in = this.getBufferedReader(); + long t0 = System.currentTimeMillis(); + long count = this.readAll(in); + in.close(); + this.println("File read in " + (System.currentTimeMillis() - t0) + "ms" + " " + count + " lines"); + } + this.println(); + } +} \ No newline at end of file Propchange: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java ------------------------------------------------------------------------------ svn:keywords = Id