Skip to content

Commit 3adad43

Browse files
committed
Added several methods and changed some named
1 parent 531cf63 commit 3adad43

File tree

3 files changed

+373
-218
lines changed

3 files changed

+373
-218
lines changed

src/main/java/BenchMark.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void readFile_BufferedReader_readLine_with_linesplit() throws IOException
7272

7373
}
7474

75-
static void readFile_InputReader_readLine() throws IOException {
75+
static void readFile_InputReader_nextLine() throws IOException {
7676

7777
double time = 0;
7878
String line;
@@ -83,18 +83,18 @@ static void readFile_InputReader_readLine() throws IOException {
8383
if (!readingFromSTDIN) in = new InputReader(new FileInputStream(f));
8484

8585
long start = System.nanoTime();
86-
while( (line=in.readLine()) != null ) {
86+
while( (line=in.nextLine()) != null ) {
8787
// System.out.println(line);
8888
}
8989
long end = System.nanoTime();
9090
time += ((end-start)/1e9);
9191

9292
}
9393

94-
System.out.println("InputReader .readLine: " + time);
94+
System.out.println("InputReader .nextLine: " + time);
9595
}
9696

97-
static void readFile_InputReader_readStr() throws IOException {
97+
static void readFile_InputReader_nextString() throws IOException {
9898

9999
String str;
100100
double time = 0;
@@ -107,15 +107,15 @@ static void readFile_InputReader_readStr() throws IOException {
107107
in = new InputReader(new FileInputStream(f));
108108

109109
long start = System.nanoTime();
110-
while( (str=in.readString()) != null ) {
110+
while( (str=in.nextString()) != null ) {
111111
// System.out.println(line);
112112
}
113113
long end = System.nanoTime();
114114
time += ((end-start)/1e9);
115115

116116
}
117117

118-
System.out.println("InputReader .readString: " + time);
118+
System.out.println("InputReader .nextString: " + time);
119119

120120
}
121121

@@ -172,7 +172,7 @@ static void readFile_BufferedReader_readLine_parseInt() throws IOException {
172172

173173
}
174174

175-
static void readFile_InputReader_readInt() throws IOException {
175+
static void readFile_InputReader_nextInt() throws IOException {
176176

177177
File f = new File(INT_FILE);
178178
InputReader in = new InputReader(System.in);
@@ -186,7 +186,7 @@ static void readFile_InputReader_readInt() throws IOException {
186186

187187
try {
188188
while(true) {
189-
int integer = in.readInt();
189+
int integer = in.nextInt();
190190
sum += integer;
191191
// System.out.println(sum);
192192
// i++;
@@ -195,11 +195,11 @@ static void readFile_InputReader_readInt() throws IOException {
195195
} catch (java.io.IOException e) { }
196196

197197
long end = System.nanoTime();
198-
System.out.println( "InputReader .readInt(): " + (end-start)/1e9 );
198+
System.out.println( "InputReader .nextInt(): " + (end-start)/1e9 );
199199

200200
}
201201

202-
static void readFile_InputReader_readDouble() throws IOException {
202+
static void readFile_InputReader_nextDouble() throws IOException {
203203

204204
File f = new File(DOUBLE_FILE);
205205
InputReader in = new InputReader(System.in);
@@ -213,17 +213,17 @@ static void readFile_InputReader_readDouble() throws IOException {
213213

214214
try {
215215
while(true) {
216-
double d = in.readDouble();
216+
double d = in.nextDouble();
217217
sum += d;
218218
}
219219
} catch (java.io.IOException e) { }
220220

221221
long end = System.nanoTime();
222-
System.out.println( "InputReader .readDouble(): " + (end-start)/1e9 );
222+
System.out.println( "InputReader .nextDouble(): " + (end-start)/1e9 );
223223

224224
}
225225

226-
static void readFile_InputReader_readDoubleFast() throws IOException {
226+
static void readFile_InputReader_nextDoubleFast() throws IOException {
227227

228228
File f = new File(DOUBLE_FILE);
229229
InputReader in = new InputReader(System.in);
@@ -237,13 +237,13 @@ static void readFile_InputReader_readDoubleFast() throws IOException {
237237

238238
try {
239239
while(true) {
240-
double d = in.readDoubleFast();
240+
double d = in.nextDoubleFast();
241241
sum += d;
242242
}
243243
} catch (java.io.IOException e) { }
244244

245245
long end = System.nanoTime();
246-
System.out.println( "InputReader .readDoubleFast(): " + (end-start)/1e9 );
246+
System.out.println( "InputReader .nextDoubleFast(): " + (end-start)/1e9 );
247247

248248
}
249249

@@ -267,21 +267,21 @@ static void timeReadingStringDataFromFile() throws IOException {
267267
System.out.println("\nPerformance of reading string data from a file: ");
268268
readFile_BufferedReader_readLine();
269269
readFile_BufferedReader_readLine_with_linesplit();
270-
readFile_InputReader_readStr();
271-
readFile_InputReader_readLine();
270+
readFile_InputReader_nextString();
271+
readFile_InputReader_nextLine();
272272
}
273273

274274
static void timeReadingIntDataFromFile() throws IOException {
275275
System.out.println("\nPerformance of reading int data from a file: ");
276276
readFile_BufferedReader_readLine_parseInt();
277-
readFile_InputReader_readInt();
277+
readFile_InputReader_nextInt();
278278
}
279279

280280
static void timeReadingDoubleDataFromFile() throws IOException {
281281
System.out.println("\nPerformance of reading double data from a file: ");
282282
readFile_BufferedReader_readLine_Double_dot_valueOf();
283-
readFile_InputReader_readDouble();
284-
readFile_InputReader_readDoubleFast();
283+
readFile_InputReader_nextDouble();
284+
readFile_InputReader_nextDoubleFast();
285285
}
286286

287287
static void timeReadingStringDataFromSTDIN() throws IOException {
@@ -297,11 +297,11 @@ static void timeReadingStringDataFromSTDIN() throws IOException {
297297
System.in.reset();
298298

299299
System.in.mark(Integer.MAX_VALUE);
300-
readFile_InputReader_readStr();
300+
readFile_InputReader_nextString();
301301
System.in.reset();
302302

303303
System.in.mark(Integer.MAX_VALUE);
304-
readFile_InputReader_readLine();
304+
readFile_InputReader_nextLine();
305305
System.in.reset();
306306

307307
}
@@ -315,7 +315,7 @@ static void timeReadingIntDataFromSTDIN() throws IOException {
315315
System.in.reset();
316316

317317
System.in.mark(Integer.MAX_VALUE);
318-
readFile_InputReader_readInt();
318+
readFile_InputReader_nextInt();
319319
System.in.reset();
320320

321321
}
@@ -329,11 +329,11 @@ static void timeReadingDoubleDataFromSTDIN() throws IOException {
329329
System.in.reset();
330330

331331
System.in.mark(Integer.MAX_VALUE);
332-
readFile_InputReader_readDouble();
332+
readFile_InputReader_nextDouble();
333333
System.in.reset();
334334

335335
System.in.mark(Integer.MAX_VALUE);
336-
readFile_InputReader_readDoubleFast();
336+
readFile_InputReader_nextDoubleFast();
337337
System.in.reset();
338338

339339
}

0 commit comments

Comments
 (0)