Skip to content

Commit b372050

Browse files
committed
Fix compilation issue.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1383504 13f79535-47bb-0310-9956-ffa450edef68
1 parent 539c976 commit b372050

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package org.apache.commons.csv.perf;
2+
3+
import java.io.BufferedReader;
4+
import java.io.FileReader;
5+
import java.io.IOException;
6+
import java.io.Reader;
7+
8+
import org.apache.commons.csv.CSVFormat;
9+
import org.junit.Ignore;
10+
import org.junit.Test;
11+
12+
/**
13+
* Tests performance.
14+
*
15+
* Only enable for your own development.
16+
*/
17+
public class PerformanceTest {
18+
19+
private final int max = 10;
20+
21+
private BufferedReader getBufferedReader() throws IOException {
22+
return new BufferedReader(new FileReader("src/test/resources/worldcitiespop.txt"));
23+
}
24+
25+
private long parse(Reader in) throws IOException {
26+
CSVFormat format = CSVFormat.DEFAULT.withSurroundingSpacesIgnored(false);
27+
long count = 0;
28+
for (Object record : format.parse(in)) {
29+
count++;
30+
}
31+
return count;
32+
}
33+
34+
private void println() {
35+
System.out.println();
36+
}
37+
38+
private void println(String s) {
39+
System.out.println(s);
40+
}
41+
42+
private long readAll(BufferedReader in) throws IOException {
43+
long count = 0;
44+
while (in.readLine() != null) {
45+
count++;
46+
}
47+
return count;
48+
}
49+
50+
@Test
51+
@Ignore
52+
public void testParseBigFile() throws Exception {
53+
long t0 = System.currentTimeMillis();
54+
long count = this.parse(this.getBufferedReader());
55+
this.println("File parsed in " + (System.currentTimeMillis() - t0) + "ms with Commons CSV" + " " + count
56+
+ " lines");
57+
this.println();
58+
}
59+
60+
@Test
61+
@Ignore
62+
public void testParseBigFileRepeat() throws Exception {
63+
for (int i = 0; i < this.max; i++) {
64+
this.testParseBigFile();
65+
}
66+
this.println();
67+
}
68+
69+
@Test
70+
@Ignore
71+
public void testReadBigFile() throws Exception {
72+
for (int i = 0; i < this.max; i++) {
73+
BufferedReader in = this.getBufferedReader();
74+
long t0 = System.currentTimeMillis();
75+
long count = this.readAll(in);
76+
in.close();
77+
this.println("File read in " + (System.currentTimeMillis() - t0) + "ms" + " " + count + " lines");
78+
}
79+
this.println();
80+
}
81+
}

0 commit comments

Comments
 (0)