#22744 [Opn->Fbk]: Split hangs on something that 'file' does quickly
ID: 22744
Updated by: wez@php.net
Reported By: tim at timcrider dot com
-Status: Open
+Status: Feedback
Bug Type: Performance problem
Operating System: Red Hat 8.0
PHP Version: 4.3.2RC1
New Comment:
Your second test script look bogus to me.
Have you considered using http://www.php.net/manual/en/ref.exec.php,
which gives the lines as an array anyway?
How big is the logfile? Do you have magic_quotes enabled?
If you leave it running, how long does it take to complete and how much
memory does it use?
Previous Comments:
------------------------------------------------------------------------
[2003-03-17 09:04:26] tim at timcrider dot com
split hangs for some reason, but doing the same logical process with
other functions returns a very quick result.
The problem is that I'm trying to process the mysqlbinlog output and
parse it for easier management. The logical process is as follows.
$sys = mysqlbinlog logfile;
This part works fine, but when I try:
$lstk = split("\n", $sys);
the script hangs for well over 5 minutes (I kill the script at that
time. However this code produces the desired results in less than 2
seconds:
$mybin = "/usr/local/mysql/bin/mysqlbinlog";
$mylogpath = "/var/lib/mysql/";
$dolog = $mylogpath."towely-bin.010";
$tmpfname = tempnam ("/tmp", "mybinlogger");
$fp = fopen($fp, $tmpfname);
fwrite($fp, $mybin $dolog);
fclose($fp);
$lstk = file($tmpfname);
unset($tmpfname);
print count($lstk)."\n";
I am using this from the command line version of php 4.3.2 RC1. Here is
my php -v:
PHP 4.3.2-RC1 (cli) (built: Mar 14 2003 13:28:33)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
with the ionCube PHP Accelerator v1.3.3r2, Copyright (c) 2001-2002,
by Nick Lindridge
If you need any other information please feel free to contact me at
tim@timcrider.com
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22744&edit=1
Thread (8 messages)