[32819] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4084 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 26 09:09:37 2013

Date: Tue, 26 Nov 2013 06:09:02 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 26 Nov 2013     Volume: 11 Number: 4084

Today's topics:
    Re: Several Topics - Nov. 19, 2013 <whynot@pozharski.name>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 26 Nov 2013 09:31:19 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Several Topics - Nov. 19, 2013
Message-Id: <slrnl98ji7.4dm.whynot@orphan.zombinet>

with <87d2lpw1bf.fsf@new.chromatico.net> Charlton Wilbur wrote:

*SKIP*

> The time hit I expect isn't in allocation; it's in copying.

That allocation is such a SOB.

> If I have @foo with 1000 strings, and I say @bar = reverse @foo, that
> requires copying 1000 strings, no? 

I'm not that sure:

	#!/usr/bin/perl

	use strict;
	use warnings;
	use Benchmark qw{ cmpthese timethese };

	my @aa = 1 .. 10e5;
	my @ab;

	cmpthese timethese -5, {
	  code00 => sub { @ab = map -$_, reverse @aa  },
	  code01 => sub { @ab = reverse @aa; $_ = -$_ foreach @ab },
	};

	__END__

Benchmark: running code00, code01 for at least 5 CPU seconds...
    code00:  6 wallclock secs ( 5.36 usr +  0.02 sys =  5.38 CPU) @  2.04/s (n=11)
    code01:  5 wallclock secs ( 5.12 usr +  0.02 sys =  5.14 CPU) @  3.31/s (n=17)
	 Rate code00 code01
code00 2.04/s     --   -38%
code01 3.31/s    62%     --

With ten time smaller list -- ten time faster, same ratio.

p.s.  With 10e6 I can't even start moving bits around -- VSZ doesn't fit
in physical memory.

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4084
***************************************


home help back first fref pref prev next nref lref last post