Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.



1. Download with

   svn checkout svn://
   Note that if you've been here before, I recently migrated from CVS to SVN. I
   have only tested this on Gentoo Linux, but I suspect it will work with other
   Linux distros, on Mac OS X and probably on a Windows machine using Cygwin. I
   don't plan to test it anywhere except Gentoo Linux. The performance really
   shouldn't depend on anything except the hardware, gcc/gprof and the Ruby

2. Change directory to "MatrixBenchmark" and run "". This will
   download (requires wget) and unpack the latest stable snapshot of Ruby and
   the YARV trunk (requires Subversion). Then it will build a profiling Ruby
   interpreter, a YARV Ruby interpreter and a profiling YARV Ruby interpreter.
   You will need to have built your Tcl, Tk and your stock Ruby *with* threads,
   since YARV uses "pthreads". The script does *not* rebuild your stock Ruby

3. The benchmark itself can be run from the command line as follows:

   ruby MatrixBenchmark.rb <dimension>

   The parameter is optional. If <dimension> is specified, it gives the
   dimension of the matrix to benchmark. The default dimension is 1. If that 
   is deliberately specified on the command line, or if no parameter is used
   on the call, the benchmark will start with dimension 1, and keep 
   benchmarking until the user gets tired, doubling the dimension each time. 
   Since doubling the dimension increases the time by (at least) a factor of
   *8*, after each benchmark is run, the user has an option to run the next
   dimension or bail out. I use this capability to determine what a "reasonable"
   dimension is for the timed/profiled tests coded in the
   script. For my 933 MHz Pentium III Coppermine, this worked out to 128.

   Most likely you'll need to run this yourself and set the dimension parameter
   in accordingly. You probably want something that runs about
   200 seconds or more in the stock Ruby interpreter. With YARV typically
   running about four times as fast as the stock Ruby, this gives you a 50
   second run for YARV, and longer runs for the profiling.

4. Now take your machine single-user to run the benchmark. You want as little
   other stuff going on as possible. Type
   ./ 2>&1 | tee run-benchmark.log
   It currently runs with the stock Ruby, then with a profiling Ruby, then 
   with a YARV Ruby, and finally a profiling YARV Ruby. It runs them with a 
   dimension of 128.
   When it's done, you will have timings for your stock Ruby, a profiling Ruby,
   YARV and a profiling YARV. The timings aren't really interesting for the
   profiling runs. The interesting results are the *profiles*. They are:
   Stable snapshot profile: profile.txt
   Stable snapshot annotated source: source.txt
   YARV profile: YARV-profile.txt
   YARV annotated source: YARV-source.txt

5. Licensing: This whole enchilada is open source software. All of my code uses
   the Ruby license, as does Ruby/YARV. The GPL applies to just about everything
   else it uses (gcc, gprof, and Linux.)
6. Updates after Mountain West Ruby Conference March 2007

   a. Fixed some ickies in the build script. It now runs inside the
      MatrixBenchmark directory, rather than requiring permissions in an
      absolute path. I cleaned up the threading conflicts with Tcl/Tk as well.
      Some day, I'll build a Rakefile. :)
   b. The benchmark itself now generates a *Hilbert* matrix instead of an
      identity matrix for inversion. This is much more of a challenge, since the
      rational numbers involved get bigger rather rapidly. Note that the Hilbert
      matrix is so poorly conditioned that it's rather useless to even attempt
      inverting it with floating point arithmetic -- only something like the
      Rational class has any hope of getting the right answer. I hacked it to
      use floating point just to see what would happen, and by something like
      dimension 16 the matrix times its inverse didn't even remotely resemble an
   c. Dropped dimension to 128. The change to a Hilbert matrix slowed this down
      a *lot*.
Something went wrong with that request. Please try again.