1 diff -Nu db1/Database.java db/Database.java
2 --- db1/Database.java Wed Jun 17 23:23:16 1998
3 +++ db/Database.java Sat Nov 30 16:02:53 2002
5 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
8 -package spec.benchmarks._209_db;
9 -import spec.harness.*;
15 private void read_fmt(String filename)
18 - spec.io.FileInputStream fis;
19 + java.io.FileInputStream fis;
23 - fis = new spec.io.FileInputStream(filename);
24 + fis = new java.io.FileInputStream(filename);
25 StreamTokenizer tok = new StreamTokenizer(fis);
31 case StreamTokenizer.TT_NUMBER:
32 - spec.harness.Context.out.println("token=TT_NUMBER: "+tok.nval);
33 + System.out.println("token=TT_NUMBER: "+tok.nval);
36 case StreamTokenizer.TT_WORD:
37 - spec.harness.Context.out.println("token=TT_WORD: "+tok.sval);
38 + System.out.println("token=TT_WORD: "+tok.sval);
46 - spec.harness.Context.out.println("ERROR opening/parsing format file "+filename);
47 + System.out.println("ERROR opening/parsing format file "+filename);
55 - spec.harness.Context.out.print("Reading database "+dbname+" ... ");
56 - spec.harness.Context.out.flush();
57 + System.out.print("Reading database "+dbname+" ... ");
61 - spec.io.FileInputStream sif = new spec.io.FileInputStream(filename);
62 - n = sif.getContentLength();
63 + java.io.FileInputStream sif = new java.io.FileInputStream(filename);
64 + n = (int) new java.io.File(".", filename).length();
70 sif = null; // 03/11/98 rrh
72 - spec.harness.Context.out.println("ERROR reading input file");
73 + System.out.println("ERROR reading input file");
81 - spec.harness.Context.out.println("Empty database");
82 + System.out.println("Empty database");
86 - spec.harness.Context.out.println("ERROR opening/reading input file \""+filename+"\"");
87 + System.out.println("ERROR opening/reading input file \""+filename+"\"");
93 - spec.harness.Context.out.print("OK\nBuilding database ...");
94 - spec.harness.Context.out.flush();
95 + System.out.print("OK\nBuilding database ...");
102 buffer = null; // 03/11/98 rrh
104 - spec.harness.Context.out.println("Done.");
105 + System.out.println("Done.");
109 @@ -209,21 +206,21 @@
112 Enumeration e = entries.elements();
113 - spec.io.FileOutputStream fos = null;
114 + java.io.FileOutputStream fos = null;
115 byte buffer[] = new byte[64*1024];
119 - spec.harness.Context.out.print("Saving database "+dbname+" ... ");
120 - spec.harness.Context.out.flush();
121 + System.out.print("Saving database "+dbname+" ... ");
122 + System.out.flush();
126 - fos = new spec.io.FileOutputStream(dbname+".dat");
127 + fos = new java.io.FileOutputStream(dbname+".dat");
129 catch (IOException ex)
131 - spec.harness.Context.out.println("\nERROR creating output file "+dbname+".dat");
132 + System.out.println("\nERROR creating output file "+dbname+".dat");
138 try {fos.write(buffer, 0, c);} catch(IOException ex)
140 - spec.harness.Context.out.println("ERROR writing to output file "+dbname+".dat");
141 + System.out.println("ERROR writing to output file "+dbname+".dat");
147 try {fos.write(buffer, 0, c);} catch(IOException ex)
149 - spec.harness.Context.out.println("ERROR writing to output file "+dbname+".dat");
150 + System.out.println("ERROR writing to output file "+dbname+".dat");
154 @@ -288,14 +285,14 @@
156 catch(IOException ex)
158 - spec.harness.Context.out.println("ERROR writing to output file "+dbname+".dat");
159 + System.out.println("ERROR writing to output file "+dbname+".dat");
163 buffer = null; // 03/11/98 rrh
164 fos = null; // 03/11/98 rrh
166 - spec.harness.Context.out.println("Done.");
167 + System.out.println("Done.");
175 - spec.harness.Context.out.println("Invalid record number ("+(rec+1)+")");
176 + System.out.println("Invalid record number ("+(rec+1)+")");
181 if ( (current_record >= index.length) || (current_record < 0) )
184 - spec.harness.Context.out.println("---- Record number "+(current_record+1)+" ----");
185 + System.out.println("---- Record number "+(current_record+1)+" ----");
187 entry = index[current_record];
189 @@ -400,18 +397,18 @@
190 s = ((String)f.nextElement());
193 - spec.harness.Context.out.print(s);
194 + System.out.print(s);
197 s = (String)i.nextElement();
198 - spec.harness.Context.out.println(s);
199 + System.out.println(s);
203 i = null; // 03/11/98 rrh
204 f = null; // 03/11/98 rrh
206 - spec.harness.Context.out.println();
207 + System.out.println();
211 @@ -445,15 +442,15 @@
214 // These create too much output for benchmark - rrh
215 - //spec.harness.Context.out.print(field);
216 - //spec.harness.Context.out.flush();
217 + //System.out.print(field);
218 + //System.out.flush();
222 try { s = dis.readLine(); }
223 catch (IOException e)
225 - spec.harness.Context.out.println("input error");
226 + System.out.println("input error");
230 @@ -485,20 +482,20 @@
234 - //spec.harness.Context.out.print(field);
235 - //spec.harness.Context.out.flush();
236 + //System.out.print(field);
237 + //System.out.flush();
241 os = (String)(((Entry)index[current_record]).items.elementAt(fn));
243 - //spec.harness.Context.out.print(" ("+os+") ");
244 - //spec.harness.Context.out.flush();
245 + //System.out.print(" ("+os+") ");
246 + //System.out.flush();
248 try { s = dis.readLine(); }
249 catch (IOException e)
251 - spec.harness.Context.out.println("input error");
252 + System.out.println("input error");
259 if ( index == null ) set_index();
260 - spec.harness.Context.out.println("Record "+(current_record+1)+" of "+index.length);
261 + System.out.println("Record "+(current_record+1)+" of "+index.length);
264 private String fieldValue;
265 @@ -546,15 +543,15 @@
269 - //spec.harness.Context.out.print(fs);
270 - //spec.harness.Context.out.flush();
271 + //System.out.print(fs);
272 + //System.out.flush();
276 try { fieldValue = dis.readLine(); }
277 catch (IOException ex)
279 - spec.harness.Context.out.println("input error");
280 + System.out.println("input error");
284 @@ -595,25 +592,25 @@
288 - //spec.harness.Context.out.print("Sorting on requested fieldname ... ");
289 - //spec.harness.Context.out.flush();
290 + //System.out.print("Sorting on requested fieldname ... ");
291 + //System.out.flush();
296 - //spec.harness.Context.out.print("Already sorted");
297 + //System.out.print("Already sorted");
302 - //spec.harness.Context.out.print("\nSearching ... ");
303 - //spec.harness.Context.out.flush();
304 + //System.out.print("\nSearching ... ");
305 + //System.out.flush();
307 if ( (rec = lookup(fieldValue, fnum)) < 0 )
308 - spec.harness.Context.out.println("NOT found");
309 + System.out.println("NOT found");
312 - spec.harness.Context.out.println();
313 + System.out.println();
317 diff -Nu db1/Main.java db/Main.java
318 --- db1/Main.java Wed Jun 17 23:23:17 1998
319 +++ db/Main.java Sat Nov 30 16:02:53 2002
321 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
324 -package spec.benchmarks._209_db;
325 -import spec.harness.*;
331 -public class Main implements SpecBenchmark
335 private boolean standalone = true;
339 - spec.harness.Context.out.println("a - add record");
340 - spec.harness.Context.out.println("b - show beginning record");
341 - spec.harness.Context.out.println("d - delete record");
342 - spec.harness.Context.out.println("e - show end record");
343 - spec.harness.Context.out.println("f - find record");
344 - spec.harness.Context.out.println("m - modify record");
345 - spec.harness.Context.out.println("n - next entry");
346 - spec.harness.Context.out.println("p - previous record");
347 - spec.harness.Context.out.println("q - quit");
348 - spec.harness.Context.out.println("w - write database");
349 - spec.harness.Context.out.println("s - sort");
350 - spec.harness.Context.out.println(". - current record number");
351 - spec.harness.Context.out.println("x - Total records");
352 - spec.harness.Context.out.println("num - goto record number 'num'");
353 + System.out.println("a - add record");
354 + System.out.println("b - show beginning record");
355 + System.out.println("d - delete record");
356 + System.out.println("e - show end record");
357 + System.out.println("f - find record");
358 + System.out.println("m - modify record");
359 + System.out.println("n - next entry");
360 + System.out.println("p - previous record");
361 + System.out.println("q - quit");
362 + System.out.println("w - write database");
363 + System.out.println("s - sort");
364 + System.out.println(". - current record number");
365 + System.out.println("x - Total records");
366 + System.out.println("num - goto record number 'num'");
372 static long runBenchmark( String[] args ) {
374 - int speed = spec.harness.Context.getSpeed();
377 // if( args.length == 0 ) {
380 long starttime = System.currentTimeMillis();
382 int iter = 1; //spec.harness.Context.getSpeed();
383 - spec.harness.Context.out.println( "db " + iter + " iterations " );
384 + System.out.println( "db " + iter + " iterations " );
386 for( int i = 0 ; i < iter ; i++ ) { //**NS**
389 } catch (IOException e) {
390 - spec.harness.Context.out.println("Error in run() method");
391 + System.out.println("Error in run() method");
393 return System.currentTimeMillis() - starttime;
398 DataInputStream dis = null;
399 - dis = new DataInputStream( new spec.io.FileInputStream( arg[1]) );
400 + dis = new DataInputStream( new java.io.FileInputStream( arg[1]) );
403 boolean changed = false;
408 - //spec.harness.Context.out.print(": "); spec.harness.Context.out.flush();
409 + //System.out.print(": "); System.out.flush();
413 @@ -148,27 +145,27 @@
416 db.add(db.getEntry(dis));
417 - //spec.harness.Context.out.println("Number of records: "+db.numRecords());
418 + //System.out.println("Number of records: "+db.numRecords());
419 // Really reduce output
420 - //spec.harness.Context.out.println(db.numRecords()+" ");
421 + //System.out.println(db.numRecords()+" ");
425 case 'h': help(); break;
428 - //spec.harness.Context.out.print("Delete record "+(db.currentRec()+1)+" y/n? ");
429 - //spec.harness.Context.out.print("d "+(db.currentRec()+1)+" y/n? ");
430 - //spec.harness.Context.out.print(db.currentRec()+1+" ");
431 - //spec.harness.Context.out.flush();
432 + //System.out.print("Delete record "+(db.currentRec()+1)+" y/n? ");
433 + //System.out.print("d "+(db.currentRec()+1)+" y/n? ");
434 + //System.out.print(db.currentRec()+1+" ");
435 + //System.out.flush();
437 if ( s.length() > 0 )
439 if ( s.charAt(0) == 'y' )
442 - //spec.harness.Context.out.println("Number of records: "+db.numRecords());
443 - //spec.harness.Context.out.println(db.numRecords());
444 + //System.out.println("Number of records: "+db.numRecords());
445 + //System.out.println(db.numRecords());
453 - spec.harness.Context.out.print("Save database (y or n)? "); spec.harness.Context.out.flush();
454 + System.out.print("Save database (y or n)? "); System.out.flush();
457 if ( (s.charAt(0) != 'n') && standalone )