in reply to Getting the size of the call stack (efficiently)
Without knowing any magic, you could check at intervals other than 1.
my $depth = 1; $depth *= 2 while ( caller $depth ); my $max = $depth - 1; my $min = $depth / 2 + 1;
Then do a binary search from there. You can probably get a bit faster if you know in advance about where your depth will be.
Update: Set starting depth to nonzero as suggested by Anno (though maybe 2 is a better value than 1 so that $depth / 2 + 1 is an integer).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting the size of the call stack (efficiently)
by Anno (Deacon) on Feb 27, 2007 at 18:39 UTC | |
by kyle (Abbot) on Feb 27, 2007 at 18:44 UTC | |
|
Re^2: Getting the size of the call stack (efficiently)
by Anno (Deacon) on Feb 27, 2007 at 20:37 UTC |