Ok, not sure how I should explain this, but I'll give it a try.
When a browser requests any given page from my webapp, it include()'s lots of
other smaller scripts that has functions that does various stuff. This is
probably how most of us do it.
But, to measure and keep track of performance, I am using a little function
that I call gauge() to keep control over the amount of time any given request
took on my server.
In a simplified structure, this is what happens when someone requests index.php
(init.php is always loaded first through auto_append)
init.php
function gauge($keyword) {
$time = getmicrotime() # another function, that just reports fractions
# of a second
$GLOBALS["page_gauge "][] = array(
"time" => $time,
"string" => $keyword
);
}
index.php
include("functi ons.php");
functions.php
( do stuff )
gauge("function s loaded");
index.php (continues)
( do stuff )
gauge("stuff done");
postprocess.phh p (php_auto_prepe nd)
gauge("webapp done");
foreach ($GLOBALS["page_gauge "] as $g){
print "$g[string]: {$time}s\n";
}
Do you get the idea? The output of the above might be - appaering after
whatever index.php outputted - something like this:
functions loaded: 0.340s
stuff done: 1.440s
webapp done: 3.340s
So, when "webapp done" was invoked, the page had taken 3.34s to execute
THE QUESTION
Ok, here comes the question! I would very much want the gauge() function to
save information about the script that invoked it, so I oculd make the output
like this:
functions.php - functions loaded: 0.340s
index.php - stuff done: 1.440s
postprocess.php - webapp done: 3.340s
For troubleshooting reasons of course.
The constant __FILE__ points to the file in which gauge was *defined* (i.e.
init.php) and superglobals like $_SERVER["PATH_TRANSLATE D"] point to index.php
Anyone knows how to find out what file called on a function?
--
Sandman[.net] 6 1324
*** Sandman wrote/escribió (Thu, 25 Aug 2005 14:01:05 +0200): The constant __FILE__ points to the file in which gauge was *defined* (i.e. init.php) and superglobals like $_SERVER["PATH_TRANSLATE D"] point to index.php
Anyone knows how to find out what file called on a function?
From the constant __FUNCTION__, I presume: http://es2.php.net/manual/en/languag...predefined.php
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Sandman wrote: Ok, not sure how I should explain this, but I'll give it a try.
When a browser requests any given page from my webapp, it include()'s lots of other smaller scripts that has functions that does various stuff. This is probably how most of us do it.
But, to measure and keep track of performance, I am using a little function that I call gauge() to keep control over the amount of time any given request took on my server.
<snip>
Don't reinvent the wheels <http://in.php.net/apd> Also, you can
*never* get reliable results with microtime and (pure) PHP based
benchmarks (except using the hooks like APD).
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com
In article <xj************ *************** **@40tude.net>,
Alvaro G Vicario <al************ ******@telecomp uter.com> wrote: *** Sandman wrote/escribió (Thu, 25 Aug 2005 14:01:05 +0200): The constant __FILE__ points to the file in which gauge was *defined* (i.e. init.php) and superglobals like $_SERVER["PATH_TRANSLATE D"] point to index.php
Anyone knows how to find out what file called on a function?
From the constant __FUNCTION__, I presume:
http://es2.php.net/manual/en/languag...predefined.php
Eh? The constant __FUNCTION__ contains the name of the current function, which
when used inside of gauge() naturally returns "gauge".
--
Sandman[.net]
debug_backtrace () should give you what you need.
In article <11************ **********@g49g 2000cwa.googleg roups.com>,
"Chung Leong" <ch***********@ hotmail.com> wrote: debug_backtrace () should give you what you need.
Yes, it's exactly what I wanted. Thanks a lot!
--
Sandman[.net]
*** Sandman wrote/escribió (Thu, 25 Aug 2005 19:21:31 +0200): http://es2.php.net/manual/en/languag...predefined.php
Eh? The constant __FUNCTION__ contains the name of the current function, which when used inside of gauge() naturally returns "gauge".
Hmmm... Yes, you're right. You should pass its value on each call or use a
global variable.
As they've already mentioned, debug_backtrace () is a better option in your
case.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
-- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: vishal |
last post by:
Hi,
I am writing my first script to execute a Oracle procedure through a
unix script. Could you tell me how do I do error handling here? How do
I know in my script if the procedure executed successfully or failed?
Thanks
#!/usr/bin/ksh
sqlplus user/password@name <<EOC
set time on
|
by: Johnny Knoxville |
last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works
fine if you add the site to favourites the normal way, but I have some
JavaScript code on a couple of pages with a link, which when you click it
bookmarks the site (much easier). The favicon is never saved if the site
is bookmarked this way. Does anyone have any ideas how to fix this??
This is the code:
<script language="JavaScript">
|
by: Juggler |
last post by:
Hi,
I have a shell script which takes three arguments, how can I call this
script from within a C++ program.
I am new to C++ programming and not sure how to accomplish this.
I tried using system() call but could make it work, must be doing
something wrong.
Appreciate any help in this regard.
Thanks,
Juggler
|
by: ebrandmark |
last post by:
I am trying to load a SCRIPT SRC tag that will result in a
document.write into a specific location in my web page but not call for
the SCRIPT SRC until the end of the page (so as not to delay the page).
The DEFER method won't work because the document.write just starts a
new page.
I was hoping to leave a DIV where the result should end up. Then at
the end of the page create a child of this DIV or another DIV that lays
on top of this...
|
by: Bart Schelkens |
last post by:
Hi,
how can I execute a piece of Java-script after a piece of vb-net-code has
been executed?
Thx
| |
by: jeet_sen |
last post by:
Hi,
My external javascript test.js contains a variable definition var a =
"Hello,world!!";
I dynamically loaded the script test.js using the following fucntion:
function loadScript(url)
{
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
|
by: Water Cooler v2 |
last post by:
Questions:
1. Can there be more than a single script block in a given HEAD tag?
2. Can there be more than a single script block in a given BODY tag?
To test, I tried the following code. None of the script gets executed.
Can someone please give me a direction as to what I may be missing?
Thanks.
|
by: ethandbrown |
last post by:
Hi All--
I'm a bit stymied here. I need to display arbitrary HTML obtained
through AJAX. The problem is when a <script> block is encountered
one can't use innerHTML to set the content, because the <script> block
won't be evaluated.
Googling around, a found the createContextualFragment() solution
which does execute script code. The following, for example, works:
|
by: PJ |
last post by:
Greetings...
I have stumbled upon a small problem.
I use Ajax to retrieve part of a page I need to update. I update a DIV
element with the HTML contents I get from another page.
It works fine.
However the HTML have a SCRIPT tag that the browser should process, but
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |