dongpu3792 2015-04-24 21:43
浏览 337

Php echo <script>标签导致重要的性能延迟[关闭]

I was making tests on my windows 2008 server with apache 2.2 and php 5.3 using Jmeter to test 300 hits on 10 seconds. I was suprised when nocited there was a huge delay with an extremely simple script

echo'
<script language="JavaScript" src="xx.js" type="text/javascript"></script>
<script language="JavaScript" ssrc="xx.js" type="text/javascript"></script>
<script language="JavaScript" src="xx.js" type="text/javascript"></script>
<script language="JavaScript" src="xx.js" type="text/javascript"></script>';

after that test, I changed the script tag for "script1" or anything else (even other valid tags such as link)

echo'<script1 language="JavaScript" src="xx.js" type="text/javascript"></script>
 <script1 language="JavaScript" ssrc="xx.js" type="text/javascript"></script>
 <script1 language="JavaScript" src="xx.js" type="text/javascript"></script>
 <script1 language="JavaScript" src="xx.js" type="text/javascript"></script>';

and the script run quickly as supposed

here are the results from jMeter. and i still don't know what causes this or how to improve it

Case 1 using tags correctly, 300 samples avg 3218 ms samples per minute:1262

Case 2 using tags, 300 samples avg 116ms samples per minute:1783

EDIT: In my test in jmeter im only donwloading and requesting a single php and not the static files, there's no reason for Jmeter to try to parse/download the jsvascript failes, it is supposed to send the request and save the response and nothing else.

If that was the case jmeter would donwload all included files .ico, .css, images, etc and have an important delay, but only happens with script tag as if php or apache were making and extra process when they find that on a string. I tried double and single quotes and also heredoc to format the string containing the script tags but is the same.

Now I runned the tests on wamp with apache 2.4 AND PHP5.4 and the issue is solved, jmeter solves both scripts in the same time. So obviously it has to do with either php or apache, maybe a module or an extension that parses de buffer before echoing but still don't know which one is causing this

  • 写回答

1条回答 默认 最新

  • dongpang2029 2015-04-24 21:46
    关注

    When using the script tag, jMeter will download xx.js. This takes some time. When using script1, jMeter will see an incorrect tag, and ignore it (or do something unspecified). In any case, xx.js will not be downloaded in that case, so less time is needed.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么