Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Getting the size of the call stack (efficiently)

by xdg (Monsignor)
on Feb 28, 2007 at 11:48 UTC ( [id://602475]=note: print w/replies, xml ) Need Help??


in reply to Getting the size of the call stack (efficiently)

Does anyone know of a more efficient method for finding just the stack depth without using multiple calls to caller() each time you need that number?

I think you'd would have to implement it in XS and adapt the underlying code for caller. Looking at pp_ctl.c in the source, it looks like caller is just walking the stack itself, but someone with more knowledge of XS and Perl guts would have to advise you on just what you need to do.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Getting the size of the call stack (efficiently)
by DrWhy (Chaplain) on Mar 01, 2007 at 00:18 UTC
    Thanks for the pointer. I've just tried an implementation of my module using the simpleminded algorithm and I find it's working acceptably quickly, so I don't have the motivation at this point to delve into XS, but I'll keep that in mind for later maybe.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2026-01-16 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.