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("functions.php");
functions.php
( do stuff )
gauge("functions loaded");
index.php (continues)
( do stuff )
gauge("stuff done");
postprocess.phhp (php_auto_prepend)
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_TRANSLATED"] point to index.php
Anyone knows how to find out what file called on a function?
--
Sandman[.net] 6 1318
*** 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_TRANSLATED"] 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******************@telecomputer.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_TRANSLATED"] 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**********************@g49g2000cwa.googlegroups .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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |