dongtaihui5131 2014-10-18 10:46
浏览 50

php中的并行性

I want to optimize part of my code to improve performance.Since my application make use of commandline tool , i think it would certainly improve performance to execute lines of code in parallel rather than executing code sequentially

<?php
$value = exec("command goes here"); //this takes time
/* Some instructions here that don't depend on $value */
/* Some instructions here that don't depend on $value */

$result = $value*2 ; //this is just a dumb example

?>  

I want to execute the codes that don't depend on value at the same time as $value so that the whole script execute faster rather that waiting for exec() to complete

  • 写回答

2条回答 默认 最新

  • dongluo9156 2014-10-18 11:23
    关注

    Unfortunately PHP always despond you in parallelism, concurrent programming, .... And I never know that why PHP doesn't support these important things and WHEN PHP WANT TO SUPPORT THESE.

    But maybe you want to use Fork in php (if you know the problems AND Troubles in Fork )

    http://php.net/manual/en/function.pcntl-fork.php

    https://codereview.stackexchange.com/questions/22919/how-to-fork-with-php-4-different-approaches

    评论

报告相同问题?

悬赏问题

  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo