我有一个PHP脚本似乎在大约20分钟后停止运行.
为了弄清楚原因,我制作了一个非常简单的脚本来查看它运行多长时间没有任何复杂的代码来混淆我.
我发现这个简单的无限循环也发生了同样的事情.在运行15到25分钟之间的某个时刻,它会在没有任何消息或错误的情况下停止.浏览器显示"完成".
我已经完成了我能想到的每一件事:
set_time_limit ( session.gc_maxlifetime in the php.ini)
memory_limit
max_execution_time
Run Code Online (Sandbox Code Playgroud)
脚本停止的点不一致.有时会停在15分钟,有时是22分钟.
请,任何帮助将不胜感激.
它托管在1and1服务器上.我联系了他们,他们不支持开发人员造成的错误.
boolean r = false ; int s = 0 ;
while (r == false) ;
{
s = getInt() ;
if (!(s>=0 && s<=2)) System.out.println ("try again not a valid response") ;
else r = true ;
}
Run Code Online (Sandbox Code Playgroud)
即使输入3或123并且循环永不终止,文本也不会显示.这里有什么不对?
我正在尝试这个简单的代码,但该死的休息不起作用......出了什么问题?
while True:
for proxy in proxylist:
try:
h = urllib.urlopen(website, proxies = {'http': proxy}).readlines()
print 'worked %s' % proxy
break
except:
print 'error %s' % proxy
print 'done'
Run Code Online (Sandbox Code Playgroud)
它应该在连接工作时离开,并返回并尝试另一个代理,如果它没有
好的,这就是我正在做的事情
我正在尝试检查一个网站,如果它发生了变化,它必须突破一段时间才能继续执行其余的脚本,但是当代理没有连接时,我从变量中得到错误,因为它是null,所以我想要的是工作作为循环来尝试代理,如果它工作,继续脚本,脚本结束,返回并尝试下一个代理,如果下一个不起作用,它将回到开始尝试第三个代理,依此类推......
我正在尝试这样的事情
while True:
for proxy in proxylist:
try:
h = urllib.urlopen(website, proxies = {'http': proxy})
except:
print 'error'
check_content = h.readlines()
h.close()
if check_before != '' and check_before != check_content:
break
check_before = check_content
print 'everything the same'
print 'changed'
Run Code Online (Sandbox Code Playgroud) 有没有人有一段代码,不windows.h用于在while循环中检查按键.基本上这个代码,但不必使用windows.h它.我想在Linux和Windows上使用它.
#include <windows.h>
#include <iostream>
int main()
{
bool exit = false;
while(exit == false)
{
if (GetAsyncKeyState(VK_ESCAPE))
{
exit = true;
}
std::cout<<"press esc to exit! "<<std::endl;
}
std::cout<<"exited: "<<std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我最近阅读了有关奇怪的C代码段的页面.大多数都是可以理解的.但我无法理解这一点:
switch(c & 3) while((c -= 4) >= 0){
foo(); case 3:
foo(); case 2:
foo(); case 1:
foo(); case 0:
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解释一下这段代码背后的逻辑是什么?它是如何工作的?
如何将以下代码转换为Windows批处理命令?
这是一个perl脚本,它在while循环中搜索文件,如果发现它退出.
use strict;
use warnings;
my $filename = 'something.txt';
while (1) {
if (-e $filename) {
print "File Exists!";
exit;
}
}
Run Code Online (Sandbox Code Playgroud) 我使用PHP来进行纬度/经度点以生成JS并在OSM Map上显示点.当我在录音中有10分钟或更长时间的暂停时,我想在地图上制作一首新曲目.
我的数据集目前在大约10个不同的轨道上有大约30000条记录(一些轨道有大约300个点,其他轨道有数千个).
我遇到了PHP的性能问题.当循环聚集了数百个点时,数据的处理速度很快,但如果轨道有数千个点,则性能会急剧下降.
以下是每个轨道的每个点所需的时间
+-----------------+------------------------------+
| Points On Track | Time To Proceed 10000 Points |
+-----------------+------------------------------+
| 21 | 0.75 |
| 18865 | 14.52 |
| 539 | 0.79 |
| 395 | 0.71 |
| 827 | 0.79 |
| 400 | 0.74 |
| 674 | 0.78 |
| 2060 | 1.01 |
| 2056 | 0.99 |
| 477 | 0.73 |
| 628 | 0.77 |
| 472 | 0.73 |
+-----------------+------------------------------+
Run Code Online (Sandbox Code Playgroud)
我们可以看到,当我在赛道上有很多分数时,表现会大幅下降.在这种特殊情况下,处理所有点需要大约30个秒.如果我将每个曲目的点数限制为500点,那么表现相当不错(我的数据集大约需要2.5秒). …
我正试图找到一种方法来优化我的算法,使运行时间为O(n²)(Big O Notation).
输入是一个包含n个元素的数组,只有正整数和负整数.我们可以假设数组已经排序.
我必须确定:对于每个r(数组的元素),r = s + t,其中s和t也是数组的元素,并且可以是相同的(s == t),或者也是零.
我试图通过检查当前数字是正数还是负数来减少我必须检查的元素数量,但是运行时间仍然太长.问题是我使用了3个while循环,这意味着在最坏的情况下运行时间为O(n³).
这是我的代码:
public static void Checker(int[] array) {
List<Integer> testlist = new ArrayList<Integer>();
int i = 0;
while (i < array.length) {
int current = array[i];
if (attached(current, array)) {
testlist.add(current);
}
i++;
}
}
public static boolean attached(int current, int[] array) {
boolean result = false;
int i = 0;
while (i < array.length && !result) {
int number1 = array[i];
int j = 0;
while (j < …Run Code Online (Sandbox Code Playgroud) 我将来自C++ Primer的代码复制为while循环的示例,并且它不输出任何内容.我正在使用g ++.
#include <iostream>
int main()
{
int sum = 0, val = 1;
// keep executing the while as long val is less than or equal to 10
while (val <= 10) {
sum += val; // assigns sum+ val to sum\
++val; // add 1 to val
}
std::cout << "Sum of 1 to 10 inclusive is "
<< sum << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) while-loop ×10
c++ ×2
java ×2
php ×2
algorithm ×1
batch-file ×1
big-o ×1
break ×1
c ×1
command ×1
duffs-device ×1
exit ×1
file ×1
line ×1
loops ×1
onkeypress ×1
optimization ×1
performance ×1
python ×1
scripting ×1
time ×1