home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Small Eiffel 0.4.8 / lib_show / bench3 / bench.e < prev    next >
Encoding:
Text File  |  1997-04-13  |  1.5 KB  |  88 lines  |  [TEXT/ttxt]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. deferred class BENCH
  5. --
  6. -- Comparison : ARRAY2 and FIXED_ARRAY2.
  7. --
  8.  
  9. feature
  10.  
  11.    -- According to the power of your computer, set `tuning'
  12.    -- to a good positive value. Default is for very small 
  13.    -- computer :
  14.    tuning: INTEGER is 1; -- 300; 
  15.  
  16. feature {NONE}
  17.    
  18.    cltn: COLLECTION2[DOUBLE] is
  19.       deferred
  20.       end;
  21.  
  22.    count1: INTEGER is
  23.       do
  24.      Result := 1 + tuning;
  25.       end;
  26.  
  27.    count2: INTEGER is
  28.       do
  29.      Result := 7 + tuning;
  30.       end;
  31.  
  32.    frozen bench is
  33.       require
  34.      cltn.count = count1 * count2
  35.       do
  36.      increment(cltn,+2.5);
  37.      increment(cltn,-2.5);
  38.      increment(cltn,+2.5);
  39.      increment(cltn,-2.5);
  40.      check_all(cltn,0.0);
  41.       end;
  42.  
  43.    increment(c: like cltn; value: DOUBLE) is
  44.       local
  45.      i1, i2: INTEGER;
  46.       do
  47.      from
  48.         i1 := c.upper1;
  49.      until
  50.         i1 < c.lower1
  51.      loop
  52.         from
  53.            i2 := c.upper2;
  54.         until
  55.            i2 < c.lower2
  56.         loop
  57.            c.put(c.item(i1,i2) + value,i1,i2);
  58.            i2 := i2 - 1;
  59.         end;
  60.         i1 := i1 - 1;
  61.      end;
  62.       end;
  63.  
  64.    check_all(c: like cltn; value: DOUBLE) is
  65.       local
  66.      i1, i2: INTEGER;
  67.       do
  68.      from
  69.         i1 := c.upper1;
  70.      until
  71.         i1 < c.lower1
  72.      loop
  73.         from
  74.            i2 := c.upper2;
  75.         until
  76.            i2 < c.lower2
  77.         loop
  78.            if c.item(i1,i2) /= value then
  79.           std_output.put_string("Error bench.%N");
  80.            end;
  81.            i2 := i2 - 1;
  82.         end;
  83.         i1 := i1 - 1;
  84.      end;
  85.       end;
  86.  
  87. end
  88.