home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / misc / benchmarks / collection / bench3 / bench.e < prev    next >
Encoding:
Text File  |  1999-06-05  |  2.6 KB  |  100 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. deferred class BENCH
  17.    --
  18.    -- Comparison : ARRAY2 Vs. FIXED_ARRAY2.
  19.    --
  20.  
  21. feature
  22.  
  23.    -- According to the power of your computer, set `tuning'
  24.    -- to a good positive value. Default is for very small
  25.    -- computer :
  26.    tuning: INTEGER is 2000; -- 300;
  27.  
  28. feature {NONE}
  29.  
  30.    cltn: COLLECTION2[DOUBLE] is
  31.       deferred
  32.       end;
  33.  
  34.    count1: INTEGER is
  35.       do
  36.          Result := 1 + tuning;
  37.       end;
  38.  
  39.    count2: INTEGER is
  40.       do
  41.          Result := 7 + tuning;
  42.       end;
  43.  
  44.    frozen bench is
  45.       require
  46.          cltn.count = count1 * count2
  47.       do
  48.          increment(cltn,+2.5);
  49.          increment(cltn,-2.5);
  50.          increment(cltn,+2.5);
  51.          increment(cltn,-2.5);
  52.          check_all(cltn,0.0);
  53.       end;
  54.  
  55.    increment(c: like cltn; value: DOUBLE) is
  56.       local
  57.          i1, i2: INTEGER;
  58.       do
  59.          from
  60.             i1 := c.upper1;
  61.          until
  62.             i1 < c.lower1
  63.          loop
  64.             from
  65.                i2 := c.upper2;
  66.             until
  67.                i2 < c.lower2
  68.             loop
  69.                c.put(c.item(i1,i2) + value,i1,i2);
  70.                i2 := i2 - 1;
  71.             end;
  72.             i1 := i1 - 1;
  73.          end;
  74.       end;
  75.  
  76.    check_all(c: like cltn; value: DOUBLE) is
  77.       local
  78.          i1, i2: INTEGER;
  79.       do
  80.          from
  81.             i1 := c.upper1;
  82.          until
  83.             i1 < c.lower1
  84.          loop
  85.             from
  86.                i2 := c.upper2;
  87.             until
  88.                i2 < c.lower2
  89.             loop
  90.                if c.item(i1,i2) /= value then
  91.                   std_output.put_string("Error bench.%N");
  92.                end;
  93.                i2 := i2 - 1;
  94.             end;
  95.             i1 := i1 - 1;
  96.          end;
  97.       end;
  98.  
  99. end -- BENCH
  100.