home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l450 / 1.ddi / MATPAK.1 / arc / BENCH.M < prev    next >
Encoding:
Text File  |  1989-05-13  |  7.2 KB  |  229 lines

  1. echo on
  2. clc
  3. %    The MATLAB benchmarks.          (May take 2-3 minutes)
  4. %
  5. %    This demo file runs a set of 7 standard benchmarks:
  6. %
  7. %        1) N=50 Real matrix multiply
  8. %        2) N=50 Real matrix inverse
  9. %        3) N=25 Real eigenvalues
  10. %        4) 4096-point complex FFT
  11. %        5) LINPACK benchmark 
  12. %        6) 1000 iteration FOR loop
  13. %        7) N=25 3-D mesh plot
  14. %
  15. %    The benchmarks illuminate computer architectural issues that
  16. %    affect the speed of software like MATLAB on different machines.
  17. %
  18. %    The time for your machine is measured and displayed versus times
  19. %    we've already taken from other standard machines. 
  20.  
  21. pause    % Hit any key to start benchmark measurements.
  22. etime(1,1);
  23. ts = zeros(1,7);
  24. clc
  25.  
  26. rand('uniform'), rand('seed',0)
  27. a = rand(50);
  28.  
  29. %     50 by 50 real multiply
  30.  
  31. t=clock;         b = a*a; ..
  32. ts(1)=etime(clock,t);
  33.  
  34. clc,disp('Benchmarks:'),disp(' '),..
  35. disp('     *        inv       eig       fft      LINPACK   for      mesh'),..
  36. disp(ts(1))
  37.  
  38.  
  39. %    N=50  real inverse
  40.  
  41. t=clock;         b = inv(a); ..
  42. ts(2)=etime(clock,t);
  43.  
  44. clc,disp('Benchmarks:'),disp(' '),..
  45. disp('     *        inv       eig       fft      LINPACK   for      mesh'),..
  46. disp(ts(1:2))
  47.  
  48.  
  49. %    N=25 real eigenvalues
  50.  
  51. a = rand(25);
  52. t=clock;         b = eig(a); ..
  53. ts(3)=etime(clock,t);
  54.  
  55. a=[];b=[];
  56. clc,disp('Benchmarks:'),disp(' '),..
  57. disp('     *        inv       eig       fft      LINPACK   for      mesh'),..
  58. disp(ts(1:3))
  59.  
  60.  
  61. %    4096 point complex FFT
  62.  
  63. a = rand(1,4096) + sqrt(-1);
  64. t=clock;         b = fft(a);..
  65. ts(4)=etime(clock,t);
  66.  
  67. a=[];b=[];
  68. clc,disp('Benchmarks:'),disp(' '),..
  69. disp('     *        inv       eig       fft      LINPACK   for      mesh'),..
  70. disp(ts(1:4))
  71.  
  72. %    N = 100 LINPACK Benchmark
  73.  
  74. [c,maxsize] = computer;
  75. if maxsize < 8192        % If computer is limited to 90x90,
  76.   t = dongarra(90);        % extrapolate 90 to 100
  77.   ts(5) = t*(100^3/3 + 100^2)/(90^3/3 + 90^2);
  78. else
  79.   ts(5) = dongarra(100);    % N=100 LINPACK for other computers
  80. end
  81.  
  82. clc,disp('Benchmarks:'),disp(' '),..
  83. disp('     *        inv       eig       fft      LINPACK   for      mesh'),..
  84. disp(ts(1:5))
  85.  
  86.  
  87. %    1000 FOR loops
  88.  
  89. a(1000) = 0;
  90. t = clock;         for i=1:1000, a(i) = 1; end,..
  91. ts(6) = etime(clock,t);
  92.  
  93. clc,disp('Benchmarks:'),disp(' '),..
  94. disp('     *        inv       eig       fft      LINPACK   for      mesh'),..
  95. disp(ts(1:6))
  96.  
  97.  
  98. %    N=25 mesh plot
  99.  
  100. a = eye(25); t = clock; mesh(a); ts(7) = etime(clock,t);
  101.  
  102. echo off
  103. times = [
  104.     76    101    107    91    256    17    66
  105.     12.1    19.5    17.5    13.7    45.8    2.97     9.1
  106.     9.45    20.9    21.0    12.3    40.9    18.0    15.8
  107.     5.2    11.6    11.2     7.1    23.5    8.7     7.4
  108.     1.95    3.52    2.82    3.33    8.1    0.62    5.0
  109.     2.6    4.5    3.7    3.5    9.5    0.69    4.3
  110.     1.84    3.6    3.4     3.5    7.7    2.0     5.0
  111.     1.31    3.0    1.74    1.89    4.9    0.87    2.2
  112.     2.6    3.1    2.9     2.9    4.9    3.2    25.0
  113.     1.05    2.0    2.42    2.15    4.08    0.52    3.22
  114.     0.71    1.32    1.21    1.16    2.96    0.93    1.31
  115.     0.76    1.42    1.38    1.8    3.46    1.02    3.9
  116.     0.8    1.09    0.86    0.79    1.88    0.49    1.26
  117.     0.34    0.72    0.98     .94    1.4    0.9     2.0
  118.     0.22    0.43    0.44    0.4    0.94    0.36    1.5
  119.     0.12    0.27    0.24    .3    .574    .09    .95
  120.     .07    .28    .54    .37     .19    .34    .69
  121.     ts];
  122. [m,n] = size(times);    % Number of benchmarked machines
  123. clc
  124. disp('        ------- Table of benchmark times -------')
  125. disp(' ')
  126. disp('            1) Macintosh (8MHz 68000)')
  127. disp('            2) PC/AT (6.0MHz/80286/EGA)')
  128. disp('            3) PC/XT (4.7MHz/8088/CGA)')
  129. disp('            4) AT&T 6300 (8MHz/8086)')
  130. disp('            5) Macintosh II (68020/68881)')
  131. disp('            6) Apollo DN3000 (16MHz)')
  132. disp('            7) Sun-3/50 (15MHz with 68881)')
  133. disp('            8) Apollo DN4000 (25MHz)')
  134. disp('            9) Your machine')
  135. disp(' ')
  136. disp('     *        inv       eig       fft     LINPACK     for       mesh')
  137. disp([times(1:8,:); times(m,:)])
  138. disp('Strike any key to continue'), pause
  139. clc
  140. disp('        ------- Table of benchmark times (continued) -------')
  141. disp('             9) MicroVAX II (VMS/D_floating)')
  142. disp('            10) Macintosh IIcx (68030/68882)')
  143. disp('            11) 80386/80387 (20MHz, 386-MATLAB)')
  144. disp('            12) Sun-386i (25MHz)')
  145. disp('            13) VAXStation 3100 (VMS/D_floating)')
  146. disp('            14) Sun-3/260 (25MHz with FPA)')
  147. disp('            15) Sun-4/110')
  148. disp('            16) Sun SparcStation')
  149. disp('            17) Ardent Titan')
  150. disp('            18) Your Machine')
  151. disp('     *        inv       eig       fft       LINPACK   for       mesh')
  152. disp(times(9:m,:))
  153. disp('Strike any key to continue'), pause
  154. ratio = ones(m,1)*times(3,:)./times;
  155. clc
  156. disp('        ------- Table of speed ratios to PC/XT -------')
  157. disp(' ')
  158. disp('            1) Macintosh (8MHz 68000)')
  159. disp('            2) PC/AT (6.0MHz/80286/EGA)')
  160. disp('            3) PC/XT (4.7MHz/8088/CGA)')
  161. disp('            4) AT&T 6300 (8MHz/8086)')
  162. disp('            5) Macintosh II (68020/68881)')
  163. disp('            6) Apollo DN3000 (16MHz)')
  164. disp('            7) Sun-3/50 (15MHz with 68881)')
  165. disp('            8) Apollo DN4000 (25MHz)')
  166. disp('            9) Your machine')
  167. disp(' ')
  168. disp('    *         inv       eig       fft       LINPACK   for       mesh')
  169. disp([ratio(1:8,:); ratio(m,:)])
  170. disp('Strike any key to continue'), pause
  171. clc
  172. disp('        ------- Table of speed ratios to PC/XT (continued) -------')
  173. disp('             9) MicroVAX II (VMS/D_floating)')
  174. disp('            10) Macintosh IIcx (68030/68882)')
  175. disp('            11) 80386/80387 (20MHz, 386-MATLAB)')
  176. disp('            12) Sun-386i (25MHz)')
  177. disp('            13) VAXStation 3100 (VMS/D_floating)')
  178. disp('            14) Sun-3/260 (25MHz with FPA)')
  179. disp('            15) Sun-4/110')
  180. disp('            16) Sun SparcStation')
  181. disp('            17) Ardent Titan')
  182. disp('            18) Your Machine')
  183. disp('    *         inv       eig       fft       LINPACK   for       mesh')
  184. disp(ratio(9:m,:))
  185. disp('Strike any key to continue'), pause
  186. merit = prod(ratio').^(1/n);
  187. clc
  188. disp(' To combine these numbers into a single "figure of merit" for')
  189. disp(' each machine, we compute the geometric mean. Here are the results:')
  190. disp(' ' )
  191. disp('    Mac       PC/AT     PC/XT     6300      Mac II    DN3000    Sun-3')
  192. disp(merit(1:7))
  193. disp('    DN4000    MicroVAX  Mac IIcx 386/387    Sun-386i VAX3100   Sun-3/FPA')
  194. disp(merit(8:14))
  195. disp('   Sun-4     Sparc     Titan     Your Machine')
  196. disp(merit(15:m))
  197. disp('Strike any key to continue'), pause
  198. clc
  199. disp('Another popular number to look at is the number of KFlops obtained')
  200. disp('from Jack Dongarra''s LINPACK benchmark (sometimes called the Argonne')
  201. disp('benchmark).  This number is often advertised by computer manufacturers')
  202. disp('in national trade magazines, comparing their computer versus others')
  203. disp('in terms of floating point performance.')
  204. disp(' ' )
  205. disp('The LINPACK benchmark compares the performance of different computer')
  206. disp('systems while solving 100''th order dense systems of linear equations in')
  207. disp('a Fortran environment.   We''re in a C environment, but this doesn''t')
  208. disp('stop us from performing the equivalent calculation.')
  209. disp(' ')
  210. disp('Strike any key to continue'), pause
  211. clc
  212.  
  213. disp('For solving a system of 100 equations, approximately')
  214. disp(' ')
  215. disp('nflops = 2/3*100^3 + 2*100^2')
  216. nflops = 2/3*100^3 + 2*100^2
  217. disp('operations are performed.  Using our times from above, we find the')
  218. disp('KFlop/second throughput for the various machines:')
  219.  
  220. KFlops = round(nflops./times(:,5)'/1000);
  221. disp(' ')
  222. disp('    Mac   AT    XT   6300 Mac II  DN3  Sun-3 DN4   MVAX  IIcx  387  S386i')
  223. disp(KFlops(1:12))
  224. disp('        VAX3100     S3/FPA      Sun-4       Sparc       Titan   Your Machine')
  225. disp(KFlops(13:m))
  226. disp('Just for reference, the Cray X-MP achieves 33,000 KFlops!')
  227. disp(' ')
  228. disp('Strike any key to continue'), pause
  229.