vaso123
vaso123

Reputation: 12391

Improve Xdebug performance

I've found many articles, and posts about this, even on stackexchange sites, I'd just like want to be sure, is it the max, what I can get from xDebug.

My scenario:

I am developing a wordpress site on localhost. Every time, when xDebug is on, when I want to load a page, the server response is 7-8 seconds. You can imagine, how frustrating it is, when you develop, and you need to reload your pages a lot of times.

If I am turn it off, (comment out from php.ini) it goes down to 1-2 seconds.

Do you see anything, what I did set badly in my configuration? If no, can you suggest me any settings what improve the speed of the server response time?

If it could be 3-4 sec, a server response with xDebug, that could be lovely. Thanks.

My environment is:

Machine

Softwares

My xDebug configuration:

Upvotes: 2

Views: 1611

Answers (1)

Benjamin Wenzel
Benjamin Wenzel

Reputation: 101

I've had some similar problems, so I decided to write a little script to toggle Xdebug.

May it helps you or others... so here it is..

#!/bin/bash

xdebugPath="/etc/php5/mods-available/xdebug.ini";
apacheRestartCommand="service apache2 reload";

showUsageMessage(){
        echo "Usage: xdebug {on|off|status}";
}

enableDebugger(){
        printf "Enabling X-debug...\r\n";
        sed  -i -e "s/^;xdebug/xdebug/g" "${xdebugPath}";
        sed  -i -e "s/^;zend/zend/g" "${xdebugPath}";
        printf "Restarting Apache...\r\n";
        ${apacheRestartCommand};
        printf "Done\r\n\r\b";
}

disableDebugger(){
        printf "Disabling X-debug\r\n";
        sed -i -e "s/^xdebug/;xdebug/g" "${xdebugPath}";
        sed -i -e "s/^zend/;zend/g" "${xdebugPath}";
        printf "Restarting Apache...\r\n";
        ${apacheRestartCommand};
        printf "Done\r\n\r\n"
}

showStatus(){
        status=$(getStatus);
        if [[ ${status} = 1 ]]; then
                echo "X-debug seems to be enabled";
        else
                echo "X-debug seems to be disabled";
        fi
}

getStatus(){
        local __result=1

        while IFS="" read -r line || [[ -n "$line" ]]; do
                if [[ ${line} == ";"* ]]; then
                        __result=0;
                fi
        done < ${xdebugPath}

        echo "$__result";
}

if [ $# = 1 ]; then
    if [ $1 == "on" ];then
    enableDebugger;
    elif [ $1 == "off" ];then
        disableDebugger;
    elif [ $1 == "status" ];then
        showStatus;
    else
        showUsageMessage;
    fi
else
    showUsageMessage;
fi

Save the text above in a new file named xdebug and mark it as executable: chmod +x xdebug.

Upvotes: 2

Related Questions