@@ -85,12 +85,24 @@ private long parse(final Reader reader, final boolean traverseColumns) throws IO
8585 return recordCount ;
8686 }
8787
88- private long testParseBigFile (final boolean traverseColumns ) throws Exception {
88+ private void println (final String s ) {
89+ System .out .println (s );
90+ }
91+
92+ private long readAll (final BufferedReader in ) throws IOException {
93+ long count = 0 ;
94+ while (in .readLine () != null ) {
95+ count ++;
96+ }
97+ return count ;
98+ }
99+
100+ public long testParseBigFile (final boolean traverseColumns ) throws Exception {
89101 final long startMillis = System .currentTimeMillis ();
90102 try (final BufferedReader reader = this .createBufferedReader ()) {
91103 final long count = this .parse (reader , traverseColumns );
92104 final long totalMillis = System .currentTimeMillis () - startMillis ;
93- System . out .println (
105+ this .println (
94106 String .format ("File parsed in %,d milliseconds with Commons CSV: %,d lines." , totalMillis , count ));
95107 return totalMillis ;
96108 }
@@ -102,25 +114,23 @@ public void testParseBigFileRepeat() throws Exception {
102114 for (int i = 0 ; i < this .max ; i ++) {
103115 bestTime = Math .min (this .testParseBigFile (false ), bestTime );
104116 }
105- System . out .println (String .format ("Best time out of %,d is %,d milliseconds." , this .max , bestTime ));
117+ this .println (String .format ("Best time out of %,d is %,d milliseconds." , this .max , bestTime ));
106118 }
107119
108120 @ Test
109121 public void testReadBigFile () throws Exception {
110122 long bestTime = Long .MAX_VALUE ;
111- long count = 0L ;
123+ long count ;
112124 for (int i = 0 ; i < this .max ; i ++) {
113125 final long startMillis ;
114126 try (final BufferedReader in = this .createBufferedReader ()) {
115127 startMillis = System .currentTimeMillis ();
116- while (in .readLine () != null ) {
117- count ++;
118- }
128+ count = this .readAll (in );
119129 }
120130 final long totalMillis = System .currentTimeMillis () - startMillis ;
121131 bestTime = Math .min (totalMillis , bestTime );
122- System . out .println (String .format ("File read in %,d milliseconds: %,d lines." , totalMillis , count ));
132+ this .println (String .format ("File read in %,d milliseconds: %,d lines." , totalMillis , count ));
123133 }
124- System . out .println (String .format ("Best time out of %,d is %,d milliseconds." , this .max , bestTime ));
134+ this .println (String .format ("Best time out of %,d is %,d milliseconds." , this .max , bestTime ));
125135 }
126136}
0 commit comments