当我提交时,此代码需要5秒才能运行。我应该怎样做才能获得更好的表现?首先我使用了file_gets_content,但这花费了更多的时间。 我拆分名称,因为我需要名字和姓氏将其添加到网址。 URL = URL +姓氏+名字。
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.6.6'
testCompile group: 'org.powermock', name: 'powermock-api-mockito', version: '1.6.6'
testCompile group: 'org.powermock', name: 'powermock-module-junit4-rule', version: '1.6.6'
答案 0 :(得分:1)
首先在PHP中执行外部请求,这意味着默认情况下,您需要与目标服务器回复给您的时间相关联。然后你实际上要求每个名字。这取决于你的联系。
以防万一我测试过你的代码(只有PHP部分),如下所示:http://sandbox.onlinephpfunctions.com/code/139050ebc5d12236ab5fa32165943ca4de027672
这就是结果:
Start (3.504753112793E-5)
Before request to Bobby Wagner (4.7922134399414E-5)
After request to Bobby Wagner (0.44589018821716)
Before request to Zach Brown (3.0994415283203E-5)
After request to Zach Brown (0.48834991455078)
Before request to Mason Foster (4.6968460083008E-5)
After request to Mason Foster (0.45868515968323)
Before request to Preston Smith (3.6001205444336E-5)
After request to Preston Smith (0.4740629196167)
Before request to Josh Norman (4.2915344238281E-5)
After request to Josh Norman (0.45651292800903)
Before request to Ryan Kerrigan (4.1007995605469E-5)
After request to Ryan Kerrigan (0.46689486503601)
Before request to Earl Thomas (4.0054321289062E-5)
After request to Earl Thomas (0.45992112159729)
Before request to Richard Sherman (4.1007995605469E-5)
After request to Richard Sherman (0.44616389274597)
Before request to Chandler Jones (4.4107437133789E-5)
After request to Chandler Jones (0.51626300811768)
Before request to Marcus Peters (4.1007995605469E-5)
After request to Marcus Peters (0.46067094802856)
Total (4.6739158630371)
您可以在此处看到每个请求大约需要半秒钟。 这就是问题,唯一可以解决的问题是,如果你可以改变目标服务/服务器,则允许一个名字列表而不是1 ...