Solved

How to trace Object-Oriented function calls in PHP without adding code to each function

Posted on 2008-06-18
15
182 Views
Last Modified: 2013-12-12
I developed an code-base (single file) where all my functions are housed. Whenever I need to call one of these functions, I "require" this file.
I rescently discovered that this is a very stupid way of doing it as the file gets parsed and compiled every time I require it, causing a huge execution time bottleneck.

Now I want to split this file into smaller files, only containing the relevant functions for each page call, and only require this small file, instead of the whole "code-base" each time.

Is there an easy way of logging/tracing which functions are called upon file execution so that I can determine which functions to include in these smaller files? I've tried using xdebug, but this logs only PHP native functions, and need extra code added per function to enable me to trace calls to my custom functions. (Correct?)
0
Comment
Question by:Kobz46
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
15 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21812027
If you have performance issues I suggest you install APC as code cache and the nyou can neglegt the size and number of functions in the file. Splitting everything up is a complicated way and will lead to a lot of issues. Sometimes it's even faster to include one file instead of the 10.
0
 

Author Comment

by:Kobz46
ID: 21812065
Looks promising. I'll install and re-run my stress test to see if this helps. Thanks.
0
 

Author Comment

by:Kobz46
ID: 21812297
Could you please assist with this error?

I've installed re2c, gawk and the apache2-threaded-dev packages.


APC-installation.gif
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 500 total points
ID: 21812338
check wether you have apxs or apxs2 or apache2-dev packe install. should be somewhere in sbin
0
 

Author Comment

by:Kobz46
ID: 21812566
OK, reinstalled apache-threaded-dev and APC installed perfectly. Gonna run some test and will report back and assign points as needed.
0
 

Author Comment

by:Kobz46
ID: 21812711
Problem. When I restart apache the page loads on the first load, upon reload, the page comes back blank. Is there anything I need to configure? When commenting out the extension in php.ini all runs fine, so the problem must be somewhere within APC.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 21812857
Are you running APC with xdebug then try to disable xdebug and test APC again.
0
 

Author Comment

by:Kobz46
ID: 21812866
Apache gives me the following in the error.log

child pid xxx exit signal segmentation fault(11)
child pid xxx exit signal segmentation fault(11)
child pid xxx exit signal segmentation fault(11)
child pid xxx exit signal segmentation fault(11)
0
 

Author Comment

by:Kobz46
ID: 21812894
xdebug in commented out in php.ini
0
 
LVL 48

Expert Comment

by:hernst42
ID: 21812939
hm strange it works here very well since years, but depending on your code APC might have bugs. which causes the opcache to fail. Does this only happen with your pages or with any page (also a phpinfo() page?)
0
 

Author Comment

by:Kobz46
ID: 21812975
All pages. Same happens on phpinfo(). Loads once after restarting apache, and then on next reload comes back blank. No source whatsoever. On every load retry, It's logs the segmentation fault in apache error log.

Apache 2.2.8 (Ubuntu)
0
 

Author Comment

by:Kobz46
ID: 21813006
strange thing is that it loads every page once, and then fails after reloading that same page.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 21813070
the 1st time it parses and conmpiles the php-file into opcode 2nd time the opcode is taken from the cache and there the opcodes semm to be invalid/broken. Any other zend_extension install. Can you post the phpinfo() output without the apc loaded to see wich other modules are installed which might cause problems?
0
 

Author Comment

by:Kobz46
ID: 21813071
OK....got it solved. Seems like it clashed with ZendOptimizer. Uncommented and all is running well. No proceeding with stress test! Phew!!
0
 

Author Comment

by:Kobz46
ID: 21813199
Just did a bencmark and I can now do 300+ average mySQL queries instead of 34. AMAZING!!
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question