- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Live & Learn.
Admin
No, that makes it speed up gradually with no other advantage. If you instead do larger manual speed-ups in response to customer requests for better performance, you can get kudos/greenbacks for not much effort.
And yes, I AM a cynical old codger :-)
Admin
Admin
But then he would have had to create a time machine to go into the future.
Admin
"Fairly" recently? As in, "the future"? I haven't seen PHP 5.4 implemented anywhere yet.
Admin
I seriously hope not, or that would mean it takes me about a quarter of a tank to drive three blocks. By the time I get home from the gas station the needle's visibly not at 'F'.
In fact my fuel gauge tends to move slower the lower the needle gets - the first quarter tank as indicated by the gauge moves quickest, and the last quarter slowest.
Admin
Thus another "optimization" opportunity in future. Job security at its finest.
Admin
Admin
Admin
you don't get it, this way, they're perfectly simulating the weight of data processing, sleep() would be just an empty facade.
Admin
Won't you hit a problem when you want an n second delay and at that time your seconds value $start is >60-n ? Then the loop will never exit.
e.g. $start=59, $secs=3, $end is always in range 0<$end<60, so $end-$start will be in range (-59,1) ,no never > 3 ?
Admin
I once had to implement a similar "feature". After fixing the performance of a report generator, we received complaints from our customer. Before the optimization, the users knew they had time to grab a coffee while the report was generated. After the fix, the heavy reports still took a while, but the others rendered within seconds. The complaint made by the users was that they had no idea how long this report would take. They didn't know if they still had time for a coffee.
After suggesting a lot of fancy progress bar implementations, the customer looked at the budget and suggested the cheapest solution possible : every report would get a 3 minute progress bar. That way, the users knew they had time for coffee even if the report was generated in milliseconds.
Admin
Admin
Admin
That said, both PHP and ASP are TRWTF.
Admin
They should have put that Jones to sleep.
Admin
Admin
Why not be nice to the user and replace the "SAVE" and "CANCEL" buttons with a "DONE - CLOSE FORM" button? Simple feedback and a way to close the form. I hate pop-ups telling me the program did it's job:(
Admin
I've seen things like this in a few places.
If someone pays for software, they want it to be complicated software.
If a programmer only took 2 hours to write it, then it obviously should be free - even if the purchaser had no chance of writing it themselves, and even if it saves the purchaser loads of money/time.
So, if your software finishes a job in the blink of an eye, or is only 20kB, then it is obviously not complicated enough, and should be free.
So, the programmer puts a slow-down loop in, and adds in some pointless libraries (or bitmaps or whatever) to bulk the program up. Now, it takes 5 minutes to do the job, and is 2MB - so it must be complicated and is well worth $20.
Even though it does exactly the same job as before.
Admin
Another untold requirement for that application is that the server room should be heating the building...
Admin
Admin
The plural of kudos is kudos.
Admin
This is very poorly designed. The whole point is that we want to gradually reduce the delay from the timing loop over time. Why build in a constant that has to be constantly adjusted? We are just creating maintenance for ourselves. This should be built into the code.
My PHP is pretty rustly, so I'll give an example with VB:
This will give a slow down that starts with 5 seconds in 2013 and gradually and automatically drops to zero by 2018-12-31.
Admin
I have to say that the manager in this case is not entirely irrational. I once noticed that the backup process for a system I worked on was ridiculously slow, and so I studied the code and, well, not to get into the details, but by accumulating larger blocks of data and writing all at once I dramatically sped up the backup. That went out with the next release ... and we promptly started getting calls from customers that "the backup wasn't working". They expected it to take half an hour or so to back up the database, and now it was taking less than a minute. They concluded that it must not really be writing the backup, the program must be failing. I recall my boss on the phone with one irate client saying, "Do you want us to make it slower again?" In the end we convinced our clients that the backup was indeed working, we didn't have to resort to slow-down loops.
Admin
Ya, but if you use it at 100%, maybe the server will die sooner, forcing the customer to purchase a new one sooner, thus more money to the developer's company.
Admin
obligatory
http://www.codinghorror.com/blog/2008/03/actual-performance-perceived-performance.html
Admin
You should have let the delay go negative in your code -- then it would go even faster over the years as it sleeps negative seconds. Soon the function would return seconds, minutes, hours, even days before it is called.
Data would be saved before it was entered. Productivity then improves, the economy recovers, then world peace.
Admin
Which is why you use a loop instead of sleep. That way, the profiler is certain to catch that this function is using time, regardless of whether you look at CPU time or wall clock time. A sleep would totally fail to be found by a CPU time profiler.
Admin
Now what do we do about a developer who beats his brains out but who isn't Zaphod Beeblebrox?
Admin
That reminds me of a customer project I had once. They wanted there to be a "loading indicator" after clicking on PDF links. I tried a fancy third-party service that loads PDFs in Flash, which would naturally load for a bit - nope, client not happy.
In the end, we put a fake "loading indicator" that would just show up for a couple of seconds, before automatically opening the PDF in a new window and hiding the loading indicator. This solution still makes me die a little inside today.
Captcha - saluto. I saluto you too!
Admin
Admin
Not at all, they delivered a solution that filled the requirements exactly: The users wanted to see the site work, and this solution does it amiably.
Admin
You can actually do this in Haskell.
Admin
TRWTF is the implementation using break instead of a simple for loop...
$start = gettime(); for( $stop = $start; $stop-$start > $sec; $stop = gettime() );
Admin
Constantly polling the clock is also going to slow down all other programs running on that server...in fact, merely underclocking would potentially leave MORE CPU time for other processes depending on how frequently this particular loop is hit...though I agree that it's still far cleaner to do it in code. Best solution would have been a proper sleep call though.
Admin
Admin
The simple solution here was to just display a message box along the lines of "NNN records processed" afterwards. Their clients liked the faster report times, and they now got verification (on the screen) that the report ran successfully. Win-win all around.
Admin
Economy collapses. Mass uprisings. World goes to war.
Admin
Admin
Using sleep rather than a hard cpu loop allows users sitting next to each other, who hit Enter at the same time to experience the same response time. A HARD CPU loop should force whoever is second to wait TWICE as long, and that, of course, is the expected system behavior, contention as well as piggy.
Admin
We had a similar issue, where the code was awfully slow. (like 10 minutes to process something). When we fixed the code (it was written by someone who didn't understand the technology), we cut it down to 10-15 seconds. The chief user called complaining he could no longer take cigarette breaks. I guess we helped his health out that way...
Admin
http://php.net/manual/en/function.sleep.php
hermm?
Admin
+1
And maybe I'm wrong, but I think if $secs is greater than the number of remaining seconds in the current minute will make the script definitely looping.
Exemple: It is 12:00:56 when the function starts. $secs = 5 and $starts = 56
So, this is the condition at every second : 12:00:56 -> 56 - 56 >= 5 -> NO BREAK 12:00:57 -> 57 - 56 >= 5 -> NO BREAK ... 12:00:59 -> 59 - 56 >= 5 -> NO BREAK 12:01:00 -> 0 - 56 >= 5 -> NO BREAK and again, and again, and again.
In fact, this is quite good for losing a long, long time.
Admin
Been there, done that. Actually my own idea. On startup of a gui I displayed a checklist. It looked rather choppy and lagging, even though it was pretty quick. I added a 50-100ms delay to each step, which smoothed it out and actually made it look faster. Noone noticed except me, but that's ok.
Admin
Wow... I dont want to live on this planet anymore.
Admin
Your comment is the Mother WTF of all WTF's
Admin
Your comment is the Mother WTF of all WTF's
Admin
Using a infinite loop was bad enough, but they had a conference room full of developers and they couldn't come up with a gradual step-down to zero delay?
Admin
Visibility of system status is Nielsen's first design rule. The users should never wonder if a change was saved.
Admin
"Someone offered "Why not add a pop-up?" Another suggested, "We can always add a message saying it finished in 0.002 seconds or whatever."
Arlen's boss shook his head. "No and no. I tried suggesting those but Jones wants none of those 'ugly' fixes as he calls them."
haha... the first heuristic of good design is display of system status. A user should NEVER wonder what happened. These are not "ugly" fixes, they are commonly-accepted design practices to tell the user what happened in the background.