Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Why it takes so much time here?

by PerlOnTheWay (Scribe)
on Dec 28, 2011 at 03:24 UTC ( #945273=note: print w/ replies, xml ) Need Help??


in reply to Re: Why it takes so much time here?
in thread Why it takes so much time here?

My system has 7GB memory,how can it run out of memory for 1.5GB?

[anony@dev-test test]$ free -g total used free shared buffers cac +hed Mem: 7 1 6 0 0 + 0 -/+ buffers/cache: 1 6 Swap: 1 1 0


Comment on Re^2: Why it takes so much time here?
Download Code
Re^3: Why it takes so much time here?
by ikegami (Pope) on Dec 28, 2011 at 03:36 UTC

    Ok, what about pure CPU speed limitations?

    15/100,000,000 s per iteration
    = 0.00000015 s per iteration
    = 150 ns per iteration

    Is that unreasonable?

      I printed the time before and after the iteration, the result is both 1325041218:

      print time . "\n"; my @a = any {$_== 92} 1..100000000; print "\n"; print time;

      So the time is not taken by the iteration..

        oh, yes it is. 1..100000000 is executed a compile-time (constant folding).
Re^3: Why it takes so much time here?
by Eliya (Vicar) on Dec 28, 2011 at 03:43 UTC
    My system has 7GB ... (6GB free)

    On my system, creating a list of 10_000_000 scalars on Perl's stack already takes roughly 700MB. So, as you have 10 times as many, 7GB is pretty close...

    Try this

    $ perl -MList::MoreUtils -e'any {<>} 1..10_000_000'

    and check its memory usage with top or ps (abort with ^C).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2014-11-26 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (171 votes), past polls