Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by PerlOnTheWay (Monk)
on Dec 28, 2011 at 03:24 UTC ( [id://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 (Patriarch) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-26 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found