matrix invert routine

Richard O'Keefe ok at mudla.cs.mu.OZ.AU
Fri Nov 17 21:17:43 AEST 1989


In article <6979 at convex.UUCP>, tchrist at convex.COM (Tom Christiansen) writes:
> This is a nice example of using small, dedicated UNIX tools to do your job.
> It is also a good example of why doing this is terribly slow.  
 
> Here's [a] perl version.  It's bit more general than the sh version
> because it doesn't have to be hacked to work for different sized
> matrices or different files, but does basically the same thing:
	[deleted]

> This is not a great test because of the resolution.  Let's
> try it on [a 10 by 10 matrix.] [The result is] more than 7.3x the real,
> 1.6x the user, and 22x on system ... on a Convex-C1. ... 'Nuff said.

> 	shell cut	6.6 real 0.8 user 4.4 sys
>	perl		0.9 real 0.5 user 0.2 sys

Not _quite_ enough said.  I timed three versions of this in the Bourne
shell on a discless Sun-3/50 serving off an Encore.

	echo `cut`	7.1 real 1.4 user 4.1 sys
	read|sort|read	2.8 real 0.6 user 1.0 sys
	read|nsort|read	1.9 real 0.4 user 0.7 sys

echo `cut`	: the version Christiansen criticised
read|sort|read	: copy the file as <colno><linemark><item> using a
		  while read ... loop, sort the result using sort(1),
		  flatten the result using another while read ... loop.
		  (Transposing by sorting is old hat, and while read is
		  the standard way to read things in the shell.)
read|nsort|read	: same as above, except using a faster sort program.

Given the difference in I/O systems, we can't compare the times of the
two machines.  What we _do_ notice is that a different shell program
using out-of-the-box SysV stuff ran twice as fast as the version that
Christiansen criticised, and that simply plugging in a faster version
of one of the standard commands chopped another third off the time.

To compare _one_ shell program with _one_ Perl program tells us little
about either the shell or about Perl.



More information about the Comp.unix.questions mailing list