|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
ob_start() and timing considerations
I had a look at xs0's script and learned the very-interesting ob_start("function_to_call_at_end");
I have liked it very much. Elegant and practical. But I think it's use could be unfair or against the rules... If I understand well, this function is to be called when max execution time has -already- elapsed. I don't know if this function has any time limit. So what if the function spends extra time on something that should be already done? I could code a last resort solution on it so my script would never get a null score. Is there a way to limit the amount of time for that function? Also, have you noted that the 30 second limit is a real-time limit? If you have a high priority heavy task on the CPU, the script could get as low as 3 seconds instead of 30. If there are 10 scripts running, I guess they will have 3 CPU seconds each. Am I wrong? |
|
#2
|
|||
|
|||
|
RE: ob_start() and timing considerations
For the real-time limit thing you are correct. I have also notice this.
For the ob_start i dont know anything. |
|
#3
|
|||
|
|||
|
RE: ob_start() and timing considerations
Well, technically, the rules say only that "I will set the max_execution_time directive in the php.ini to 30 seconds". Because it is not said that the script shouldn't run longer than that, ...
But anyway, I'd say that using this technique does not provide a significant advantage - the output is generated in like 0.02 seconds... Are you sure about "real time"? I checked PHP source for Linux, and it uses a signal handler that is supposed to be counting processor time... Never actually measured it, though... Perhaps it's different on Windows... |
|
#4
|
||||
|
||||
|
RE: RE: ob_start() and timing considerations
Quote:
Yes, it is not against the rules. And I like it. But it could lend to abuse. That's why I think that it should be taken in consideration. Perhaps there should be a rule that limits the code that can be run after time limit. Quote:
I am rather sure. When I was running my scrabble scripts I had to let the machine alone for the 30 seconds in order to get better results. Also, if you look at your clock, you can see that in no case you'll have to wait beyond 30 seconds. I did some efforts to estimate CPU time/usage of the script via POSIX interface, but I found that the time limit was not 30 CPU seconds, but 30 real world seconds. Tip: If you are under Linux, try a heavy operation like "rpm --rebuilddb" during script execution... On my desktop the script gets approximately half the time. I don't know an equivalent for Windows... |
|
#5
|
|||
|
|||
|
RE: ob_start() and timing considerations
I also used the ob_start technique this time around and I considered exactly what you mentioned gatopeich. You could, theoretically, spend another hour and a half in your ob_start callback function doing whatever you want. That, however, would clearly violate the spirit of the rules. I'm with xs0 when he says that producing the output is of minimal consequences. In fact, since in the last contest, there wasn't even an output portion, I'd propose that output isn't what is being tested and ought to come "for free". Boiled down, what I'm saying is: as long as you don't do anything in the ob_start callback that is meant to improve your score, it should be fine. Doing output only and there shouldn't be a problem. Since we're already relying on peer code review to spot anyone who is cheating or fixing scores or whatever, perhaps we can just include this as one of the things we look for when reviewing the winner's code.
|
![]() |
| Viewing: Codewalkers Forums > PHP Contests > Older Contests > ob_start() and timing considerations |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|