473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

What is that function called again? Time taken to do script.

Hi,

I recall a function that would tell me how long it took to generate an
output.
But for the life of me I cannot remember it.

Dow anybody know it? Or do I have to write something myself, (using time?).

Sims
Jul 17 '05 #1
9 2321
Sims wrote:
Hi,

I recall a function that would tell me how long it took to generate an
output.
But for the life of me I cannot remember it.

Dow anybody know it? Or do I have to write something myself, (using
time?).

Sims

Maybe there is a function I don't know about, but I have seen most people do
this by running microtime() at the beginning and end of the script, and
subtracting. I think its useless for your average script which takes less
than 2 seconds, because microtime is in no way precise.
Jul 17 '05 #2
"Sims" <si*********@hotmail.com> wrote:
I recall a function that would tell me how long it took to generate an
output.
But for the life of me I cannot remember it.

Dow anybody know it? Or do I have to write something myself, (using
time?).


You can use microtime(). Example of what you're after in the manual:
http://uk.php.net/manual/en/function.microtime.php

HTH;
JOn
Jul 17 '05 #3

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn**************************@130.133.1.4...
"Sims" <si*********@hotmail.com> wrote:
I recall a function that would tell me how long it took to generate an
output.
But for the life of me I cannot remember it.

Dow anybody know it? Or do I have to write something myself, (using
time?).


You can use microtime(). Example of what you're after in the manual:
http://uk.php.net/manual/en/function.microtime.php


Thanks all, I will use microtime, I just want to make sure that the scrip
does not take too long.

But on the same subject, what is "too long" how small should I keep my
script in KB for it to be 'acceptable?
I saw an article that a page should not take 'more than 30 seconds', surely
30 seconds is far too long for one page.

Regards.

Sims.
Jul 17 '05 #4
On Mon, 19 Apr 2004 12:56:00 +0100, "Sims" <si*********@hotmail.com>
wrote:

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn**************************@130.133.1.4.. .
"Sims" <si*********@hotmail.com> wrote:
> I recall a function that would tell me how long it took to generate an
> output.
> But for the life of me I cannot remember it.
>
> Dow anybody know it? Or do I have to write something myself, (using
> time?).
You can use microtime(). Example of what you're after in the manual:
http://uk.php.net/manual/en/function.microtime.php


Thanks all, I will use microtime, I just want to make sure that the scrip
does not take too long.

But on the same subject, what is "too long" how small should I keep my
script in KB for it to be 'acceptable?


You can't really infer a correlation between the filesize of the
script and its execution time. A script that performs a lot of
database queries or fetches data from some other server will/may take
longer than one that does not.
I saw an article that a page should not take 'more than 30 seconds', surely
30 seconds is far too long for one page.


If you are developing an intranet page that generates a complex report
and the users know that it will take that long, you can probably get
away with it. On a shared server, the server owners may not like your
script taking up that much CPU time, and users may not wait 30
seconds.

It really depends on the situation.

--
David ( @priz.co.uk )
Jul 17 '05 #5
But on the same subject, what is "too long" how small should I keep my
script in KB for it to be 'acceptable?
You can't really infer a correlation between the filesize of the
script and its execution time. A script that performs a lot of
database queries or fetches data from some other server will/may take
longer than one that does not.


Sorry by file size I wanted to say the packet been sent to the browser/user,
not the size of the script.
Because yes, sending a file bigger than 100/200k would not be practical,
(and more importantly if it can be monitored then it useful to know).

How would I calculate/estimate the size of the packet sent?
I saw an article that a page should not take 'more than 30 seconds', surely30 seconds is far too long for one page.


If you are developing an intranet page that generates a complex report
and the users know that it will take that long, you can probably get
away with it. On a shared server, the server owners may not like your
script taking up that much CPU time, and users may not wait 30
seconds.

It really depends on the situation.


Of course, but knowing how long it takes might also be useful.
If I do not want *any* page to be more than x seconds then I could, (try
and), monitor those pages.

Sims
Jul 17 '05 #6
Sims wrote:
Sorry by file size I wanted to say the packet been sent to the browser/user,
not the size of the script.
Because yes, sending a file bigger than 100/200k would not be practical,
(and more importantly if it can be monitored then it useful to know).

How would I calculate/estimate the size of the packet sent?


PHP is server-side - the file size of the PHP script has absolutely no
correlation to the amount of data sent to the user's browser. You could
easily write a tiny PHP script that could send megabytes of data to a
user's browser.

eg.
<?php
for( $i=0; $i<1000000000; $i++ ) {
echo "Here's some data<br>";
}
?>

Ultimately, the size of what the user will receive in their browser
depends on the

1) The size of the generated HTML
2) embedded/linked content within that HTML file - images, flash, movies
etc.

So are asking how using PHP you can calculate the total of #1 & #2 for a
given script output?
Jul 17 '05 #7
>
PHP is server-side - the file size of the PHP script has absolutely no
correlation to the amount of data sent to the user's browser. You could
easily write a tiny PHP script that could send megabytes of data to a
user's browser.

eg.
<?php
for( $i=0; $i<1000000000; $i++ ) {
echo "Here's some data<br>";
}
?>

Ultimately, the size of what the user will receive in their browser
depends on the

1) The size of the generated HTML
2) embedded/linked content within that HTML file - images, flash, movies
etc.

So are asking how using PHP you can calculate the total of #1 & #2 for a
given script output?


But as a server side operation php create something that will be sent to the
browser, (HTML page, links etc).
So yes I would be curious to see the size of what is sent, (including
images).

But I realise that it is not an easy task but using

<?php
for( $I=0; $i<1000000000; $i++ ) {
echo "Here's some data<br>";
}
?>

I can guess how big the final output will be, (and add the size of images).

With the size I could then make an educated guess if the pages is too big
and needs to be trimmed.

Sims
Jul 17 '05 #8
"Sims" <si*********@hotmail.com> wrote in message
news:c6************@ID-162430.news.uni-berlin.de...

PHP is server-side - the file size of the PHP script has absolutely no
correlation to the amount of data sent to the user's browser. You could
easily write a tiny PHP script that could send megabytes of data to a
user's browser.

eg.
<?php
for( $i=0; $i<1000000000; $i++ ) {
echo "Here's some data<br>";
}
?>

Ultimately, the size of what the user will receive in their browser
depends on the

1) The size of the generated HTML
2) embedded/linked content within that HTML file - images, flash, movies
etc.

So are asking how using PHP you can calculate the total of #1 & #2 for a
given script output?
But as a server side operation php create something that will be sent to

the browser, (HTML page, links etc).
So yes I would be curious to see the size of what is sent, (including
images).

But I realise that it is not an easy task but using

<?php
for( $I=0; $i<1000000000; $i++ ) {
echo "Here's some data<br>";
}
?>

I can guess how big the final output will be, (and add the size of images).
With the size I could then make an educated guess if the pages is too big
and needs to be trimmed.

Sims


Use output buffering and use ob_get_length to get the size of the data being
streamed. Note that your images are actually separate retrieves. Most like
you are including <img> tags. Right? As such, you will output a stream of
html and the browser will then make an additional request to get the actual
image. You could determine what images will be requested as you build the
html and then get their sizes and add them to the size of the html you find
in the output buffer.

See http://us2.php.net/manual/en/ref.outcontrol.php for more info on output
buffering/control.

- Virgil
Jul 17 '05 #9
On Mon, 19 Apr 2004 15:33:20 +0100, "Sims" <si*********@hotmail.com>
wrote:
How would I calculate/estimate the size of the packet sent?


Opera has an "Info" panel that displays the size of the requested
resource and also the total size of all the inline elements (images,
stylesheets, etc).
If you are developing an intranet page that generates a complex report
and the users know that it will take that long, you can probably get
away with it. On a shared server, the server owners may not like your
script taking up that much CPU time, and users may not wait 30
seconds.


Of course, but knowing how long it takes might also be useful.
If I do not want *any* page to be more than x seconds then I could, (try
and), monitor those pages.


If your page does a lot of queries or other processing then it's
probably useful to check how long it takes.

--
David ( @priz.co.uk )
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
56
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...)...
3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
0
by: Nathanael | last post by:
Hi Guys, You probably have heard of affiliate marketing before but what exactly is affiliate marketing? In this introduction you'll find an explanation of the basics of affiliate marketing. The...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
8
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
27
by: Steven D'Aprano | last post by:
I thought that an iterator was any object that follows the iterator protocol, that is, it has a next() method and an __iter__() method. But I'm having problems writing a class that acts as an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.