SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    List scripts that have been called

    Hi guys,

    Is there a way of listing what scripts are being called?
    My CMS is running very slow when it is online but runs very fast when developed locally.

    Thanks in advance,
    Michael

  2. #2
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,026
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    General Purpose tracing function. Includes what you're asking for

    PHP Code:

    function trace() {
        if (!
    headers_sent()) {
            
    header("HTTP/1.0 520 Programmer debug trace");
            
    header("Content-Type: text/plain");
        }
        
        echo 
    "Trace: \n\n";
        
        foreach (
    func_get_args() as $item) {
            if (
    is_array($item) || is_object($item)) {
                
    print_r($item);
            }
            else if (
    is_bool($item)) {
                echo (
    $item) ? 'true' 'false';
            }
            else if (
    is_null($item)) {
                echo 
    'Null Var';
            }
            else {
                echo 
    $item;
            }
            
            echo 
    "\n";
        }
        
        echo 
    "\n\n-----------------------------------------------\nGET:\n";
        
    print_r($_GET);
        
        echo 
    "\n\n-----------------------------------------------\nPOST:\n";
        
    print_r($_POST);
        
        echo 
    "\n\n-----------------------------------------------\nStack Trace:\n";
        
        
    debug_print_backtrace();

        echo 
    "\n\n-----------------------------------------------\nIncluded Files:\n";
        
        
    print_r(get_included_files());
        
        exit;

    This function replaces the technique of inserting echo or print_r in your code followed immediately by exit. It can be overloaded so you can check as many or as few variables as you need. After printing out those variables with print_r or echo (as appropriate) it then does a print_r of the $_GET var, $_POST var, Debug Strack and the included files. Incidently, the function get_included_files is what you where directly asking about.

    One other wrinkle is that if your code hasn't sent output yet the trace function will send the headers needed to put the browser in text mode to make reading the print_r results easier.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats exactly what I was looking for.

    I've found that Active record is calling 15 files which IMHO is far too much so i'll be removing AR asap.

    Thanks mate.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How have you determined that those 15 files make it slow?

    profile the code. At most basic, you use microtime() to time sections of code. Time the entire script. Then time 2 parts seperately. One will probably be very obvious it's the slower half. Now split that into 2 and so on...

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The load time according to the FF plugin 'Extended Statusbar' was between 15-20 seconds. I've removed AR from a page with similar load time and it;s loading in around 5 seconds now. But still far too long for my liking lol.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •