|
-
Jun 24th, 2002, 01:38 PM
#1
Thread Starter
New Member
Echoing Long Strings Parses Extremely Slow
I am hoping someone here can offer an explanation of what is happening and possibly offer a few suggestions in improving the efficiency of this method.
Echoing long strings takes a very long time, a string of about 25000 characters takes about 0.7 seconds to "process".
Now, I figured, ok, lets make the strings smaller. So, to test it out, I produced the following code:
PHP Code:
$output = explode("\n", $output);
while (list ($line_num, $line) = each ($output)) {
echo $line, "\n";
}
Basically, this code creates an array, breaks apart the elements wherever there is a line break. Now, what is strange, this actually is MUCH faster than echoing the single variable, something is really not right here. In terms of comparison, this on an average string of 25000 characters and 1000 line breaks, is about 4x faster than simply echoing the string at one time.
If anyone can offer any kind of explanation, or a more efficient method of echoing this string, it would be appreciated.
Regards,
Shawn
-
Jun 24th, 2002, 03:25 PM
#2
Thread Starter
New Member
Lots of information at the following URL's I have been working with...
http://www.sitepointforums.com/showt...&postid=478866
http://www.invisionboard.com/forums/...ST&f=7&t=12538
It appears to be either a bug in PHP or a problem with the PHP configuration on Dragon.
-
Jun 24th, 2002, 05:09 PM
#3
ok little confused here. I read your links and if that guy is getting better results then you on the same version of php why is php at fault?
I will run tests as well but I fail to see why echoing a 25000 line string is needed. put it in a text box if you have to do that. might just be faster. and you can have it as readonly.so
so you have that code, where is output coming from?
-
Jun 24th, 2002, 07:33 PM
#4
Fanatic Member
Originally posted by scoutt
...I fail to see why echoing a 25000 line string is needed...
i recon 'ey; thats a hell of a lot of words.
-
Jun 25th, 2002, 01:42 PM
#5
hello? well you post the samething on 3 different forums but you never comment on this one.
this is not a bug in php. and they will tell you that. if you want to work on getting things to run fast, try optimizing 38000 lines into mysql and out of mysql. before you get a 30 second connection error. your script is nothing. as you can't tell me where the output is coming from or how it is made.
you also have to think that it takes time to send your page form the server to your browser. as you can notice form all the other posts that most of them that did it are on localhost and that is why they are fast. it ain't going to parse your page and send it all at once. it takes time to send it to your browser from another server, if you aren't connected straight to it.
-
Jun 28th, 2002, 08:11 AM
#6
well I see you posted to the other forums about the problem was not a bug in php but you leave this one hang'n. It seems that I was right in my last post.
just to comment on what that guys said, the smartest guy in the company, makes since. think about it. you send one huge packet one way and when you split it up you send a bunch of smaller packets. you tell me which one will go faster.
and if you want to report a bug you don't go to php.net but you goto bugs.php.net and you didn't go there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|