*** empty log message ***
[cacao.git] / tests / jvm98 / db.diff
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
4 @@ -30,9 +30,6 @@
5   * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
6   */
7  
8 -package spec.benchmarks._209_db;
9 -import spec.harness.*;
10 -import spec.io.*;
11  import java.util.*;
12  import java.io.*;
13  
14 @@ -51,11 +48,11 @@
15     private void read_fmt(String filename)
16        {
17        int len, act;
18 -      spec.io.FileInputStream fis;
19 +      java.io.FileInputStream fis;
20        String f;
21  
22        try {
23 -         fis = new spec.io.FileInputStream(filename);
24 +         fis = new java.io.FileInputStream(filename);
25           StreamTokenizer tok = new StreamTokenizer(fis);
26  
27           tok.commentChar(0);
28 @@ -81,11 +78,11 @@
29              switch(tok.ttype)
30                 {
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);
34                 break;
35  
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);
39                 break;
40  
41                 case '"':
42 @@ -108,7 +105,7 @@
43           }
44        catch (IOException e)
45           {
46 -         spec.harness.Context.out.println("ERROR opening/parsing format file "+filename);
47 +         System.out.println("ERROR opening/parsing format file "+filename);
48           System.exit(1);
49           };
50  
51 @@ -135,12 +132,12 @@
52        boolean OK;
53        byte buffer[] = null;
54  
55 -      spec.harness.Context.out.print("Reading database "+dbname+" ... ");
56 -      spec.harness.Context.out.flush();
57 +      System.out.print("Reading database "+dbname+" ... ");
58 +      System.out.flush();
59  
60        try {
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();
65            buffer = new byte[n];
66  
67            int bytes_read;
68 @@ -150,7 +147,7 @@
69            sif.close();
70           sif = null;           // 03/11/98 rrh
71            if ( act != n ){
72 -            spec.harness.Context.out.println("ERROR reading input file");
73 +            System.out.println("ERROR reading input file");
74              //System.exit(1);
75              return;
76            }
77 @@ -160,18 +157,18 @@
78        {
79        if ( n == 0 )
80           {
81 -         spec.harness.Context.out.println("Empty database");
82 +         System.out.println("Empty database");
83           return;
84           }
85  
86 -      spec.harness.Context.out.println("ERROR opening/reading input file \""+filename+"\"");
87 +      System.out.println("ERROR opening/reading input file \""+filename+"\"");
88  //    System.exit(1);
89        };
90  
91        entry = new Entry();
92  
93 -      spec.harness.Context.out.print("OK\nBuilding database ...");
94 -      spec.harness.Context.out.flush();
95 +      System.out.print("OK\nBuilding database ...");
96 +      System.out.flush();
97  
98        n = buffer.length;
99        s = e = 0;
100 @@ -200,7 +197,7 @@
101  
102        buffer = null;     // 03/11/98 rrh
103  
104 -      spec.harness.Context.out.println("Done.");
105 +      System.out.println("Done.");
106        }
107  
108  
109 @@ -209,21 +206,21 @@
110        Entry entry;
111        String s;
112        Enumeration e = entries.elements();
113 -      spec.io.FileOutputStream fos = null;
114 +      java.io.FileOutputStream fos = null;
115        byte buffer[] = new byte[64*1024];
116        int c, len;
117  
118  
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();
123  
124        try
125           {
126 -         fos = new spec.io.FileOutputStream(dbname+".dat");
127 +         fos = new java.io.FileOutputStream(dbname+".dat");
128           }
129        catch (IOException ex)
130           {
131 -         spec.harness.Context.out.println("\nERROR creating output file "+dbname+".dat");
132 +         System.out.println("\nERROR creating output file "+dbname+".dat");
133  //       System.exit(1);
134           }
135  
136 @@ -246,7 +243,7 @@
137                 {
138                 try {fos.write(buffer, 0, c);} catch(IOException ex)
139                    {
140 -                  spec.harness.Context.out.println("ERROR writing to output file "+dbname+".dat");
141 +                  System.out.println("ERROR writing to output file "+dbname+".dat");
142  //                System.exit(1);
143                    }
144  
145 @@ -267,7 +264,7 @@
146              {
147              try {fos.write(buffer, 0, c);} catch(IOException ex)
148                 {
149 -               spec.harness.Context.out.println("ERROR writing to output file "+dbname+".dat");
150 +               System.out.println("ERROR writing to output file "+dbname+".dat");
151  //             System.exit(1);
152                 }
153  
154 @@ -288,14 +285,14 @@
155               }
156           catch(IOException ex)
157              {
158 -            spec.harness.Context.out.println("ERROR writing to output file "+dbname+".dat");
159 +            System.out.println("ERROR writing to output file "+dbname+".dat");
160  //          System.exit(1);
161              }
162  
163        buffer = null;     // 03/11/98 rrh
164        fos = null;        // 03/11/98 rrh
165  
166 -      spec.harness.Context.out.println("Done.");
167 +      System.out.println("Done.");
168        }
169  
170  
171 @@ -346,7 +343,7 @@
172           printRec();
173           }
174        else
175 -         spec.harness.Context.out.println("Invalid record number ("+(rec+1)+")");
176 +         System.out.println("Invalid record number ("+(rec+1)+")");
177        }
178  
179  
180 @@ -387,7 +384,7 @@
181        if ( (current_record >= index.length) || (current_record < 0) )
182           return;
183  
184 -      spec.harness.Context.out.println("---- Record number "+(current_record+1)+" ----");
185 +      System.out.println("---- Record number "+(current_record+1)+" ----");
186  
187        entry = index[current_record];
188  
189 @@ -400,18 +397,18 @@
190           s = ((String)f.nextElement());
191  
192           if ( s != null )
193 -            spec.harness.Context.out.print(s);
194 +            System.out.print(s);
195           else
196              {
197              s = (String)i.nextElement();
198 -            spec.harness.Context.out.println(s);
199 +            System.out.println(s);
200              }
201           }
202  
203        i = null;     // 03/11/98 rrh
204        f = null;     // 03/11/98 rrh
205  
206 -      spec.harness.Context.out.println();
207 +      System.out.println();
208        }
209  
210  
211 @@ -445,15 +442,15 @@
212           if ( field != null )
213              {
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();
219              }
220           else
221              {
222              try { s = dis.readLine(); }
223              catch (IOException e)
224                 {
225 -               spec.harness.Context.out.println("input error");
226 +               System.out.println("input error");
227  //             System.exit(1);
228                 }
229  
230 @@ -485,20 +482,20 @@
231           if ( field != null )
232              {
233              // Reduce output
234 -            //spec.harness.Context.out.print(field);
235 -            //spec.harness.Context.out.flush();
236 +            //System.out.print(field);
237 +            //System.out.flush();
238              }
239           else
240              {
241              os = (String)(((Entry)index[current_record]).items.elementAt(fn));
242              // Reduce output
243 -            //spec.harness.Context.out.print(" ("+os+") ");
244 -            //spec.harness.Context.out.flush();
245 +            //System.out.print(" ("+os+") ");
246 +            //System.out.flush();
247  
248              try { s = dis.readLine(); }
249              catch (IOException e)
250                 {
251 -               spec.harness.Context.out.println("input error");
252 +               System.out.println("input error");
253  //             System.exit(1);
254                 }
255  
256 @@ -520,7 +517,7 @@
257     public void status()
258        {
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);
262        }
263  
264     private String fieldValue;
265 @@ -546,15 +543,15 @@
266           if ( fs != null )
267              {
268              // Reduce output
269 -            //spec.harness.Context.out.print(fs);
270 -            //spec.harness.Context.out.flush();
271 +            //System.out.print(fs);
272 +            //System.out.flush();
273              }
274           else
275              {
276              try { fieldValue = dis.readLine(); }
277              catch (IOException ex)
278                 {
279 -               spec.harness.Context.out.println("input error");
280 +               System.out.println("input error");
281  //             System.exit(1);
282                 }
283  
284 @@ -595,25 +592,25 @@
285        if ( fn != fnum )
286           {
287           // Reduce output
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();
292           shell_sort(fn);
293           }
294        else
295           {
296 -         //spec.harness.Context.out.print("Already sorted");
297 +         //System.out.print("Already sorted");
298           }
299  
300  
301        // Reduce output
302 -      //spec.harness.Context.out.print("\nSearching ... ");
303 -      //spec.harness.Context.out.flush();
304 +      //System.out.print("\nSearching ... ");
305 +      //System.out.flush();
306  
307        if ( (rec = lookup(fieldValue, fnum)) < 0 )
308 -         spec.harness.Context.out.println("NOT found");
309 +         System.out.println("NOT found");
310        else
311           {
312 -         spec.harness.Context.out.println();
313 +         System.out.println();
314  
315           while ( rec >= 0 )
316              {
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
320 @@ -23,33 +23,30 @@
321   * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
322   */
323  
324 -package spec.benchmarks._209_db;
325 -import spec.harness.*;
326 -
327  import java.io.*;
328  import java.util.*;
329  
330  
331 -public class Main implements SpecBenchmark
332 -{
333 +public class Main {
334 +
335         private boolean standalone = true;
336  
337  static void help()
338     {
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'");
367     }
368  
369  
370 @@ -57,7 +54,7 @@
371  
372      static long runBenchmark( String[] args ) {
373      
374 -     int speed =  spec.harness.Context.getSpeed();   
375 +     int speed = 100;   
376      
377  //      if( args.length == 0 ) {
378          if( speed == 100 ) {
379 @@ -95,13 +92,13 @@
380      long starttime = System.currentTimeMillis();
381      try {
382         int iter = 1; //spec.harness.Context.getSpeed();
383 -       spec.harness.Context.out.println( "db " + iter + " iterations " );
384 +       System.out.println( "db " + iter + " iterations " );
385         
386         for( int i = 0 ; i < iter ; i++ ) { //**NS**
387              run(argv);
388         }
389      } catch (IOException e) {
390 -        spec.harness.Context.out.println("Error in run() method");
391 +        System.out.println("Error in run() method");
392      }
393      return System.currentTimeMillis() - starttime;
394    }
395 @@ -113,7 +110,7 @@
396     String s;
397     Database db;
398     DataInputStream dis = null;
399 -   dis = new DataInputStream( new spec.io.FileInputStream( arg[1]) );
400 +   dis = new DataInputStream( new java.io.FileInputStream( arg[1]) );
401     
402     boolean OK = true;
403     boolean changed = false;
404 @@ -127,7 +124,7 @@
405     while ( OK )
406        {
407        // Reduce output
408 -      //spec.harness.Context.out.print(": "); spec.harness.Context.out.flush();
409 +      //System.out.print(": "); System.out.flush();
410  
411        s = dis.readLine();
412  
413 @@ -148,27 +145,27 @@
414           {
415           case 'a':
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()+" ");
422              changed = true;
423           break;
424  
425           case 'h':  help(); break;
426  
427           case 'd':
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();
436              s = dis.readLine();
437             if ( s.length() > 0 )
438                {
439                if ( s.charAt(0) == 'y' )
440                   {
441                   db.remove();
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());
446                    changed = true;
447                   }
448                 }
449 @@ -213,7 +210,7 @@
450  
451     if ( changed )
452        {
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();
455        s = dis.readLine();
456  
457        if ( (s.charAt(0) != 'n') && standalone )