/home/mjd/bin/mailpager 647
Return-Path: mjd@plover.com
Return-Path: <mjd@plover.com>
Delivered-To: mjd-filter-vacation-deliver@plover.com
Delivered-To: mjd-filter-vacation@plover.com
Delivered-To: mjd-filter@plover.com
Delivered-To: mjd@plover.com
Message-ID: <19971122023740.9516.qmail@plover.com>
To: bwk@bell-labs.com, cvanwyk@drew.edu
cc: mjd@plover.com
Subject: Trials of Timing
Organization: Plover Systems
Date: Fri, 21 Nov 1997 21:37:40 -0500
From: Mark-Jason Dominus <mjd@plover.com>

I was a little puzzled by one of your sample programs.  In the section
on `file copying', you said:

	The first task is to copy input to output, uninterpreted and
	unexamined... 

But the Perl program you show does not do this.  It says:

	while (<>) {
	  chop;
	  print $_;
	}

The `chop' here removes the trailing newline from each line of the
input; in this program is it not only superfluous but also incorrect,
since the program

	while (<>) {
	  print $_;
	}

is what you want.  This is worrisome.  Is there code here that isn't
shown?	I suspect so, that you translated 

	{ print }

with `a2p', and omitted the code that preceded the loop.  Is this so?
If not, I wonder whether any of the other programs generated incorrect
output that you didn't notice.

On my system, the correct (chopless) version ran about 25% faster than
the incorrect version.  I tested it on an input Bible of:

  % wc /tmp/bible 
  99465  820797 4330159 /tmp/bible

I also found your 2x speedup here very surprising.  When I modified
the program to read the input in one chunk instead of in lines, it ran
about six times faster.

I was also puzzled by your reliance on `a2p'.  Although nobody would
expect you to hand-tune the test programs for performance, relying on
an automatic machine translation from another language seems like a
bad idea, and likely to skew the results.  I don't think, for examlpe,
that you would have considered benchmarking C code that had been
obtained frmo `awk2c'.  

a2p was not necessarily designed to produce speedy code, but rather
code that would be compatible with awk.  I am not too familiar with
a2p, but I notice for example that the a2p translation of

	{ print }

performs some argument parsing, and needlessly removes the trailing
newline character from each input line with `chop' and then implicitly
replaces it again.


Should you wish to investigate Perl further, I would be happy to
assist you in preparing more representative Perl programs for your
various tasks.



Mark-Jason Dominus 	  			               mjd@plover.com
/home/mjd/bin/mailpager 651
Return-Path: CVANWYK@drew.edu
Return-Path: <CVANWYK@drew.edu>
Delivered-To: mjd-filter-vacation-deliver@plover.com
Delivered-To: mjd-filter-vacation@plover.com
Delivered-To: mjd-filter@plover.com
Delivered-To: mjd@plover.com
Date: Sun, 23 Nov 1997 13:48:00 -0500 (EST)
From: "CHRISTOPHER J. VAN WYK" <CVANWYK@drew.edu>
Subject: Re: Trials of Timing
To: mjd@plover.com
Message-id: <01IQCNM38E4AAZT6I8@drew.edu>
X-VMS-To: _IN%"mjd@plover.com"
X-VMS-Cc: CVANWYK,BWK@RESEARCH.BELL-LABS.COM
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII

Thanks very much for your email.

We've heard similar--though not quite as detailed--comments
from other Perl users, and had decided already that we need
to revise those tests so they more more like a native speaker
of Perl would write.  That, in fact, is our agenda for thee
coming week.

Sincerely,

Chris Van Wyk
