#1 (permalink)  
Old 09-12-2006, 03:02 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,445
PHP Performance Question

I am working on something that requires a function to run itself multiple times, and I'm curious just how much something like that may affect performance and speed.

I realize my initial statement is a little hard to follow, so I've provided an example.

PHP Code:
function checkArray($input) {
    foreach(
$input as $key => $item) {
        if(
is_array($item)) {
            echo 
"<dl><dt>".$key."</dt><dd>";
            
checkArray($item);
            echo 
"</dd></dl>";
        }
        else {
            echo 
"<dl><dt>".$key."</dt><dd>".$item."</dd></dl>";
        }
    }

Notice how, within that function, I am calling that same function again. It's possible, depending on how many dimensions an array may have, that multiple instances of that function could be running within each other (obviously we're going to have as many simultaneous instances of that function as we have dimensions in our multi-dimensional array, so if the array is nested 7 levels deep - God only knows why an array would be nested that deeply, but bear with me - then I'd be running that function inside of itself 7 times).

Again, I'm just curious how much something like that may effect performance. Unfortunately, I don't really have any good benchmarking tools to test it out with various dimensions of multi-dimensional arrays.
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote

  #2 (permalink)  
Old 11-23-2006, 11:24 PM
Registered User
 
Join Date: Sep 2003
Posts: 94
Send a message via AIM to seccondbest Send a message via Yahoo to seccondbest
count the times it runs the arrys

then I'd be running that function inside of itself 7 times.

all i can say if I would try this i would shut down so be carefull even the fastest pc might lock up if the levels keep going deeper, maybe you should add a counter and only call the function as many times as specified in that counter and maybe add a frefresh function after the counter reaches max so it would start over instead of running your PC into a wall.
__________________
Im learning, but i still need help.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Perl Regex to PHP curtiss Programming and Scripting 3 07-14-2006 10:14 PM
Show Integer As Text in PHP? curtiss Programming and Scripting 1 05-27-2006 10:12 AM
PHP and <a name> Leprakawn Programming and Scripting 6 02-02-2006 04:28 PM
How to create a PHP "Top Ten" link list? Leprakawn Programming and Scripting 1 01-20-2006 09:19 AM
Stupid Question About PHP curtiss Programming and Scripting 3 11-22-2005 12:11 AM


All times are GMT -5. The time now is 05:20 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter