views:

41

answers:

3

Hi all. Basically, I was doing some testing using apache bench. The file i was testing takes 2 seconds to execute (its optimised, it connects to an external server hence the slowdown)

Basically I found that the more concurrent useres i emulated, the more executions of the file i could do per second.

Is there anyway that i can do something like this in php? :

<?php

execute_file('file.php');
execute_file('file.php');
execute_file('file.php');
execute_file('file.php');
execute_file('file.php');

?>

That would execute the file 5 times but would NOT wait for the files to finish downloading so the above example would quickly call the 5 functions then exit.

Im assuming somesort of timeout would be used?

A: 

How about?

exec('file.php');
Sarfraz
doesnt work for me, the script just hangs when i call exec
Ozzy
A: 

May be something about that?

function execute_file($file) {
    $pid = pcntl_fork();
    if ($pid === 0) {
        exec("php $file");
    }
}
Alexey Shockov
A: 

exec('file.php');

cosy