Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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

Replies are listed 'Best First'.
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).

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).

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2019-01-16 01:43 GMT
Find Nodes?
    Voting Booth?
    After Perl5, I'm mostly interested in:

    Results (274 votes). Check out past polls.