dsa1234569 2012-11-04 03:18
浏览 27
已采纳

繁忙的PHP脚本使其他脚本变慢 - 如何?

On my localserver, XAMPP environment, I'm running a test PHP script that takes 20 seconds to run, but uses only 2MB of memory and 10% CPU.

When I open a new window and run the same script at the same time as the first, it takes over 30 seconds for both scripts to finish.

--The script is a simple for loop that writes to mysql DB, InnoDb, 200 times.

Shouldn't the script take the same amount of time, but use more system resources?

As in, scale linearly.

Why is this?

  //the code in all its glory-- Post extends a CRUD class
  // These are the values to be saved:
   $values = array(
  'id' => '',
  'content' => 'This is the VALUE'
                 );
  //And the action. I know-Saving Mysql in a loop is a no-no-- 
    //for demonstration only  
   for($i=0; $i<250; $i++){

   $object = new Post($values); //instantiate the Post Class with values
   $object->create($values);   //save the values to the Db. The end
                           }

20 seconds.

  • 写回答

1条回答 默认 最新

  • douxin20081125 2012-11-04 03:20
    关注

    Seems like it is creating a lock on the DB. So 1 can not complete before the other one does.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度