[plt-scheme] Re: Using PLT Scheme libs elsewhere?

From: SpinyNorman (jmcaxolotl at gmail.com)
Date: Thu May 17 23:23:32 EDT 2007

Share?  I'm flattered.  Here it is, and my only claim at this point is
that hey, it works.  Algorithmic insights are more than welcome.

(require (lib "md5.ss"))
(define (md-file-chunks filename chunk-size)
  (define port (open-input-file filename 'binary))
  (let loop ()
    (begin
      (display (md5 (read-bytes chunk-size port)))
      (newline))
    (if (not (eof-object? (peek-byte port)))
	(loop))))



On May 17, 10:28 pm, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
> On May 17, 2007, at 10:22 PM, SpinyNorman wrote:
>
> > I have a little program, written in Java, that bites off a chunk of a
> > file (of a cmdline-specified size), does an md5 on it, prints the
> > result, and repeats while there is more file.  This program is 105
> > lines long, largely due to the non-optional exception handling hoohah.
>
> > I also have a 9-line Scheme function which does almost exactly the
> > same thing.  But it runs about 10-20 times slower.
>
> Are you willing to share so we can take a look?
>
> > It is claimed that Petite Chez Scheme would speed this up quite a bit.
>
> If it speeds it up by 20x, I would be extremely surprised.
>
> > 1. Is it frowned on to use MzScheme libraries in other environments?
> > Are there syntactic differences that make it infeasible to do so?
>
> No problem.
>
> > 2. If the answer to that is something other than a call for my
> > immediate immolation, what kind of difficulty would be anticipated in
> > adapting md5.ss to the Petite environment?
>
> 1. Make sure your program is well designed. The 20x sounds like
> an algorithmic problem. (Example: use (= (length l) 0) for null?
> checks.)
>
> 2. Find the hotspot. Work on it.
>
> -- Matthias
>
>
>
> > _________________________________________________
> >   For list-related administrative tasks:
> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>   For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.