ronman Posted June 6, 2008 Share Posted June 6, 2008 Hi, I'm new to phpfreaks and looking forward to learning and contributing lots of good stuff. Here's my problem: I'm running a binary (the excellent graphviz) from PHP using the exec() function. But it's about 40x slower than running the same binary from a command line. The system is RedHat/apache. what can be done? This is too slow. Here's more: From a command line, I use strace to see how fast Graphviz runs. It can render my largest image from a shell command line in 0.02 seconds. strace says that it runs in exactly the same time, sometimes less, when called by exec(). That is, by running the following in PHP: exec( strace -c <graphviz command>) But putting timing statements around exec(): display_time(...) exec(<graphviz command>) display_time(...) reveals that it takes about 0.8 seconds to return from the exec(), even though what has executed within the exec only takes 0.02 or less. These values have been fairly consistent for months. There must be a better way. (i even thought of using inotify to run graphviz outside of PHP whenever PHP wrote out a file, but the version of RedHat I'm tied to doesn't support inotify). Thanks in advance. Ron Link to comment https://forums.phpfreaks.com/topic/108925-getting-more-efficiency-out-of-the-exec-function/ Share on other sites More sharing options...
DarkWater Posted June 6, 2008 Share Posted June 6, 2008 Sorry, but I think that you need to just live with it. I don't think you can speed up the function any more. Link to comment https://forums.phpfreaks.com/topic/108925-getting-more-efficiency-out-of-the-exec-function/#findComment-558823 Share on other sites More sharing options...
ronman Posted June 6, 2008 Author Share Posted June 6, 2008 So exec() always increases the time to execute whatever it calls by 40x? Say it isn't so. There must be some memory allocation issue that could be addressed. Or perhaps running PHP as a CGI in Apache is the problem rather than running it as an Apache module. Has anyone experimented with this? (I'm using PHP 4.4.6, and the hosting company updates to the latest version of Apache whatever it is) Ron Link to comment https://forums.phpfreaks.com/topic/108925-getting-more-efficiency-out-of-the-exec-function/#findComment-558830 Share on other sites More sharing options...
DarkWater Posted June 6, 2008 Share Posted June 6, 2008 Yeah, that's probably why. I was going to say that usually exec() doesn't take long at all. It's probably the fact that you're not running it as a module. Link to comment https://forums.phpfreaks.com/topic/108925-getting-more-efficiency-out-of-the-exec-function/#findComment-558832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.