Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
对于每一行:
完整代码:
For each row:
Complete code:
这不是更容易吗?
在我的网络服务器上工作。
当使用“Nobody”给您的代码时,您遇到页面无法加载的问题的原因是您达到了服务器的最大页面执行时间。它可以处理小数据样本,因为它可以在 30 秒内完成(或者无论你的服务器的最大执行时间是多少。我的是 30),但大量的实时数据处理时间太长。
我尝试对两者进行速度比较,但由于超时,我也无法让其他解决方案工作。相反,我从您的实时数据中抽取了 40 行样本,并使用该样本对两种解决方案进行了速度测试。
我的解决方案在 10 次运行中平均耗时 0.0001 秒
没有人的解决方案在 10 次运行中平均耗时 0.0007 秒,
我建议找到一种方法来完成整个任务,而不必单独循环每一行。
Wouldn't this be easier?
Working on my web server.
The reason you were having trouble with the page not loading when using the code that 'Nobody' gave you is that you're hitting the maximum page execution time for your server. It worked with a small sample of data because it can do that in under 30 seconds (or whatever your server's max execution time is. Mine is 30), but the huge piece of live data is taking it too long to process.
I tried doing a speed comparison between the two but I also couldn't get the other solution to work due to the timeout. Instead I took a sample of 40 lines from your live data and ran a speed test on both solutions using that.
My solution averaged 0.0001 seconds in 10 runs
Nobody's solution averaged 0.0007 seconds in 10 runs
I'd suggest finding a way to do the whole thing without having to individually loop over each line.