benchmark.m version 1.3

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

benchmark.m version 1.3

Francesco Potorti`-9
Version 1.3 of benchamrk.m is appended below.  It is the latest on I
will post.  If more versions will come out, you will find them at
ftp://fly.cnuce.cnr.it/pub/benchmark.m

---------------------- benchmark.m --------------------
bm_version = ["bm ", "1.3"];

# Benchmark for octave.
# Francesco Potorti` <[hidden email]>
# Fri Mar 22 16:37:46 MET 1996

printf ("Octave benchmark version %s\n", bm_version);

# To add reference times for your machine run the benchmark and
# add the values contained in the bm_mytime vector.
#
# Reference times by Francesco Potorti` <[hidden email]>
bm_refname = "DEC Alpha 2100";
bm_reftime = [0.440  1.31  1.46  0.610  1.04];
# Reference times by Evan Thomas <[hidden email]>
bm_refname = "Sun Sparc 2";
bm_reftime = [4.07  11.0   8.00   4.14  6.66];

# Use clock() if cputime() does not work on this particular port of octave.
# In this case, time will be computed on a wall clock, and will make sense
# only on a machine where no other processes are consuming significant cpu
# time while the benchmark is running.
global bm_uses_cputime = (cputime() != 0);
if (!bm_uses_cputime)
  disp ...
    ("WARNING: if other processes are running the figures will be inaccurate");
endif
function t = bm_start ()
  global bm_uses_cputime
  if (bm_uses_cputime)
    t = cputime();
  else
    t  = clock();
  endif
endfunction
function et = bm_stop (t);
  global bm_uses_cputime
  if (bm_uses_cputime)
    et = cputime()-t;
  else
    et = etime(clock(),t);
  endif
endfunction
 
# Used for the lsode test.  
clear xdot
function xdot = xdot (x, t)
  r = 0.25; k = 1.4; a = 1.5; b = 0.16; c = 0.9; d = 0.8;
  xdot(1) = r*x(1)*(1 - x(1)/k) - a*x(1)*x(2)/(1 + b*x(1));
  xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2);
endfunction

#
# Do benchmark
#
function [name, time] = bm_test(f,rep) # Actual test functions
  global s0 t;
  start = bm_start();
  for i=1:rep
    if (f == 1)
      name="Matrix inversion (LAPACK)";
      bm_x=inv(hadamard(8));
    elseif(f==2)
      name="Schur decomposition (LAPACK)";
      bm_x=schur(hadamard(7));
    elseif(f==3)
      name="Differential equation (LSODE)";
      bm_x=lsode("xdot",[1;2],(t=linspace(0,50,200)'));
    elseif(f==4)
      name="Fourier transforms (FFTPACK)";
      bm_x=ifft2(fft2(hadamard(8)));
    elseif(f==5)
      name="for loop";  
      for i=1:6000;bm_x=i^2;endfor
    endif
  endfor
  time = bm_stop(start)/rep;
endfunction

bm_targetaccuracy = 0.025;
bm_minrepetitions = 7;
bm_maxseconds = 60;
bm_runtime = 3;
bm_mytime = bm_reftime;

printf ("Speed of octave %s on %s relative to %s\n", ...
        version(), computer(), bm_refname);
for f = 1:length(bm_reftime)
  res = [];
  bm_test(f,1); # increase the RSS, load things
  [name,time] = bm_test(f,1); # evaluate name and time
  printf("%-33s", name); # print name
  rep = round(bm_runtime/time); # no. of repetitions per run
  for runs = 1:bm_maxseconds/bm_runtime # do runs
    [name,time] = bm_test(f,rep); # run
    res(runs) = bm_reftime(f) / time; # store relative performance
    if (runs < bm_minrepetitions) # jump rest of for loop
      continue
    endif
    # purged results: remove min and max elements
    pres = res((res != max(res)) & (res != min(res)));
    if (std(res)/mean(pres) < bm_targetaccuracy)
      break
    endif
  endfor # end of repetitions loop
  bm_mytime(f) = bm_reftime(f)/mean(pres);
  # print 95% confidence interval
  printf("%5.2f +/- %.1f%% (%d runs)\n", ...
         mean(pres), 200*std(res)/mean(pres), runs*rep);
endfor
clear bm_x
# Display the geometric mean of the results
printf ("-- Performance index (%s): %.2g\n\n", bm_version, ...
        prod(bm_reftime./bm_mytime)^(1/length(bm_reftime)))

Reply | Threaded
Open this post in threaded view
|

Re: benchmark.m version 1.3

niles-5

Here's a bug....some of us don't have as fast a machine as you... :)

 rep = max(1,round(bm_runtime/time)); # no. of repetitions per run

You need to require 'rep' be >= 1.

        Rick Niles.