Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loops, output buffering and execution time

Status
Not open for further replies.

KarterJK

Programmer
May 11, 2004
27
0
0
US
Hello to all,

I am a confused on looping and output buffering in regards to execution time.

I have 3000+ music files stored
they have a file structure
Library as main directory
then artists by directory
then albums by directory
then the songs for that album
Example
C:/Library/3 Doors Down/Away from the Sun/01 - Away from the sun.mp3

would be a typical file layout

I parse through the directories and read the files into an array
I then go through and read the ID3tags to update a data base with the info

file location|file name|artist|album|title|track etc.....

SO herein lies the problem, this takes about 35-45 seconds to parse all the information and my script will time out unless I increase the script execution time.

While I am sure my coding is not the most efficient, its how I do it.

I was using a DO WHILE LOOP during the update portion
but it seems that no ouput is performed until the entire loop is finished.

Is that correct?

or if I were to use a FOR LOOP will output info be perform for each execution? or does it also wait until the entire script is finished.

I am just confused on how this all works..

I hope I explained it correctly

Thanks for any input you may have




 
First, a word from a comment in my php.ini file :

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).

Most PHP installations have output buffering turned on because that is the default. If your PHP installation has output buffering turned on, PHP will collect the output of your scripts, regardless of the type of loop use, and output it all at once.

I personally have no problems setting max_execution_time to 0 (turning off execution time limits) on systems where only I or a trusted few post code to be executed.




Want the best answers? Ask the best questions! TANSTAAFL!
 
ummmmm

Thanks for the reply, yes I thought about doing that...
but was reluctant, I don't know why LOL

so let me ask them...

I I were to read my directories into an array as I do now
and had it set to a global array
and then transferred control to another PHP page
would that restart the execution timer OR
does it still consider it as all one script?

Thank you for your inout

 
No.

When the first script stops, the connection between the browser and server is severed. The only way to maintain the values in variables between script runs is by using session variables.

Probably the best starting place for session variables is the online manualn page for session_start()



Want the best answers? Ask the best questions! TANSTAAFL!
 
My real problem is that I used to do Visual Basic programming and PHP is powerful enough, that I try to do things that should be really run locally LOL

Thanks again

 
The idea that a web application is a discontinuous set of small, separate applications is something a lot of desktop programmers have trouble getting their heads around.

Whe usually happens is that they ignore the problem until their site code gets sufficiently complex, then suddenly they're forced to figure out a better solution than their earlier workarounds.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Some additions (in pursuit of;):
You have more than 3000 music files, it's more than 10Gb (or near?). If the script scans all these files (reads them in memory) to extract some info, what's a duration of this op on typical server? I think, it's much more than 30 sec as usually...
 
ArkM said:
You have more than 3000 music files, it's more than 10Gb (or near?). If the script scans all these files (reads them in memory) to extract some info, what's a duration of this op on typical server? I think, it's much more than 30 sec as usually...

the program is just extracting the ID tag info and putting it into a database, it usually takes about 45 seconds, its closer to 15Gb

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top