From: Michael Neumann Date: 2001-10-30T05:30:06+09:00 Subject: [ruby-talk:23749] Re: Some inspirations from REBOL Ryan Leavengood wrote: > > Maybe great, but very slow. Why not make it a standard C-extension and > > distribute it with Ruby? It would run on any platform. > > Yes that is certainly a possibility. But there is no guarantee it will > run on any platform. But I suppose if Ruby could be ported to that > platform then that library could. But pure Ruby is always more portable > than C. > > > I've implemented LZ77, LZ78, LZW, RLE and BWT (bzip) in pure Ruby and > > they are really slow. > > How slow is really slow? Does it take seconds to process small data or > is it just a lot slower than C? Because sure, if you compare it to > highly optimized compiled code it will be a lot slower, especially if > you write it inefficiently in Ruby (for example using += instead of << > with Strings.) But if it can process a meg a second or so then I think > that would be sufficient for most people. Well, I did not spent much time with optimizing it. But compressing a 5.3 MB large file with a blocksize of 4000 bytes using BWT (without any other compression algorithm like RLE) took on my PC (Athlon 1000) 9 min. bzip2 uses a block size between 100,000 and 900,000 bytes and compresses the same file in only 5.7 (bs 100,000) or 7.5 (bs 900,000) seconds. Using a block-size of 500 bytes with the Ruby program speeds the whole up by factor 2.5 (4 min), so the Ruby implementations largely depends on the block-size. But I must also note that the BWT compress (better: sort) routine is only 9 lines long (decompress is 16). Regards, Michael -- Michael Neumann merlin.zwo InfoDesign GmbH http://www.merlin-zwo.de