• (cs) in reply to Some Damn Yank
    Some Damn Yank:
    Not just computers. Pay close attention to your car's fuel gauge and odometer. When the needle just starts to move off "F" you have about 3/4 of the tank left. When it hits the 3/4 mark you have about 1/2 tank left. When it hits the 1/2 mark you have 1/4-1/3 of a tank left. Because that's the way people like it. When they made an accurate gauge they got letters complaining about poor gas mileage, so they gave up and now give the public what they want.
    The problem here is (good or bad) that rental car companies rely on the fuel gauges to determine how much to fleece you when you turn your vehicle back at the end of the rental. Yes, sometimes they tell you it is a full tank even when it isn't!

    Live & Learn.

  • JustSomeGuy (unregistered) in reply to Ash
    Ash:
    Next step, over the course of a few months, increase the slowdown by a small amount every day, say 50ms.

    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 :-)

  • fa (unregistered) in reply to faoileag
    faoileag:
    Ryan Fox:
    Back in the 90s, we needed speed-up loops. Now that it's the future, things happen too fast, so we need slow down loops.
    Back in the 80s I once needed a slow-down-loop as well. I wrote a little game (think snake) in BASIC and it worked smoothly. I ran the BASIC through a compiler, and boy, was it fast! Then I rewrote the game in Z80-Assembler and I had to insert a slow-down-loop because otherwise the head of the snake would crash into the opposite wall before I could hit one of the control keys :-)

    Ah, those were the days...

    I think qBASIC came with snake - would've saved you the effort

  • (cs) in reply to fa
    fa:
    faoileag:
    Ryan Fox:
    Back in the 90s, we needed speed-up loops. Now that it's the future, things happen too fast, so we need slow down loops.
    Back in the 80s I once needed a slow-down-loop as well. I wrote a little game (think snake) in BASIC and it worked smoothly. I ran the BASIC through a compiler, and boy, was it fast! Then I rewrote the game in Z80-Assembler and I had to insert a slow-down-loop because otherwise the head of the snake would crash into the opposite wall before I could hit one of the control keys :-)

    Ah, those were the days...

    I think qBASIC came with snake - would've saved you the effort

    But then he would have had to create a time machine to go into the future.

  • TortoiseWrath (unregistered) in reply to Pock Suppet
    Pock Suppet:
    until fairly recently, PHP didn't allow using getting the value of a returned array element without using an intermediate variable

    "Fairly" recently? As in, "the future"? I haven't seen PHP 5.4 implemented anywhere yet.

  • (cs) in reply to Some Damn Yank
    Some Damn Yank:
    Not just computers. Pay close attention to your car's fuel gauge and odometer. When the needle just starts to move off "F" you have about 3/4 of the tank left.

    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.

  • Mark Hartman (unregistered) in reply to GoatCheez

    Thus another "optimization" opportunity in future. Job security at its finest.

  • jimmy (unregistered) in reply to GUIF
    GUIF:
    The problem isn't speed. It was vague feedback to the user. Sure, you don't want a pop up, but there are many ways to tell the user that the save actually saved something, perhaps a small bit of text "Congrats! It Was Saved! YEA!", perhaps another page "it was saved!". Etc.
    I'm sure tghe article said they had that considered, but the problem was the user wasn';t gonna accept no affidavit that we'd saved their work, they had to see the system go to EFFORT!
  • Bill C. (unregistered) in reply to Answer
    Answer:
    Question:
    Does this not break if you go off the end of a minute? E.g. try to do a 5-second pause starting at xx:xx:58?
    It's comparing Eunuchs timestamps.
    Doesn't matter, had secs.
  • (cs) in reply to GoatCheez
    GoatCheez:
    This is still a WTF. They should have used a sleep function. By NOT using a sleep function, while the application is waiting, it is pegging a CPU core at 100%. By using this form of a wait they are reducing the scalability of their application and increasing power usage. They should have used a sleep.

    you don't get it, this way, they're perfectly simulating the weight of data processing, sleep() would be just an empty facade.

  • Peter (unregistered)

    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 ?

  • MrMike (unregistered)

    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.

  • faoileag (unregistered) in reply to fa
    fa:
    faoileag:
    I wrote a little game (think snake) in BASIC
    I think qBASIC came with snake - would've saved you the effort
    This was not about playing the game, this was about writing it myself. I had a rather simple home computer but no printer so playing games or understanding how it worked were the only things I could do with it. Ok, one could also have cataloged one's records or whatever one would catalog at the time with it as well, but I never sank that low ;-)
  • faoileag (unregistered) in reply to Peter
    Peter:
    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 ?

    ["sec"] returns seconds since Unix epoch start.

  • foo (unregistered) in reply to A Nerd With a View
    A Nerd With a View:
    They went to PHP, and that's a good thing?

    Why not go to ASP.Net?

    (Sits back and watches the cage match.)

    I do appreciate your attempt at trolling, but a little more effort is required.

    That said, both PHP and ASP are TRWTF.

  • Thomas (unregistered) in reply to GoatCheez
    GoatCheez:
    This is still a WTF. They should have used a sleep function. By NOT using a sleep function, while the application is waiting, it is pegging a CPU core at 100%. By using this form of a wait they are reducing the scalability of their application and increasing power usage. They should have used a sleep.

    They should have put that Jones to sleep.

  • (cs) in reply to Thomas
    Mark Bowytz:
    After go-live, kudos were passed down
    No, kudos were not passed down. Kudos was passed down, since it is a singular noun in Greek that just happens to end in 's'. </nitpick>
  • ronpaii (unregistered) in reply to jimmy
    jimmy:
    GUIF:
    The problem isn't speed. It was vague feedback to the user. Sure, you don't want a pop up, but there are many ways to tell the user that the save actually saved something, perhaps a small bit of text "Congrats! It Was Saved! YEA!", perhaps another page "it was saved!". Etc.
    I'm sure tghe article said they had that considered, but the problem was the user wasn';t gonna accept no affidavit that we'd saved their work, they had to see the system go to EFFORT!

    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:(

  • (cs)

    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.

  • Bebert (unregistered) in reply to GoatCheez

    Another untold requirement for that application is that the server room should be heating the building...

  • Bob (unregistered) in reply to GoatCheez
    GoatCheez:
    By using this form of a wait they are reducing the scalability of their application and increasing power usage. They should have used a sleep.
    By using this form, they have prepared for an opportunity to demonstrate improvements not only in response time but also scalability and resource usage.
  • (cs) in reply to Silverhill
    Silverhill:
    Mark Bowytz:
    After go-live, kudos were passed down
    No, kudos were not passed down. Kudos was passed down, since it is a singular noun in Greek that just happens to end in 's'.

    </nitpick>

    The plural of kudos is kudos.

  • jay (unregistered)

    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:

    Sub slowdown()
            Dim end_date = New DateTime(2018, 12, 31)
            If DateTime.Now > end_date Then Exit Sub
            ' To get a delay of 5 seconds, 5 years out, what is the slop of the line?
            ' Calculate number of seconds in 5 years, then divide by 5 seconds
            ' (Ignores leap years, but close enough.)
            Dim slope As Integer = (365 * 24 * 60 * 60 * 5) / 5
            ' Calculate delay
            ' There are 10 million ticks per second. Convert to milliseconds
            Dim delay As Integer = (end_date.Ticks - DateTime.Now.Ticks) / 10000 / slope
            System.Threading.Thread.Sleep(delay)
    End Sub
    

    This will give a slow down that starts with 5 seconds in 2013 and gradually and automatically drops to zero by 2018-12-31.

  • jay (unregistered)

    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.

  • Beernutts (unregistered) in reply to GoatCheez
    GoatCheez:
    This is still a WTF. They should have used a sleep function. By NOT using a sleep function, while the application is waiting, it is pegging a CPU core at 100%. By using this form of a wait they are reducing the scalability of their application and increasing power usage. They should have used a sleep.

    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.

  • (cs)
  • anonymous (unregistered) in reply to jay

    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.

  • Troy (unregistered) in reply to Joat

    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.

  • Norman Diamond (unregistered) in reply to Silverhill
    Silverhill:
    Mark Bowytz:
    After go-live, kudos were passed down
    No, kudos were not passed down. Kudos was passed down, since it is a singular noun in Greek that just happens to end in 's'.

    </nitpick>

    True. Congratulation was passed down.

    Now what do we do about a developer who beats his brains out but who isn't Zaphod Beeblebrox?

  • BigC (unregistered)

    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!

  • (cs) in reply to Norman Diamond
    chubertdev:
    Silverhill:
    Mark Bowytz:
    After go-live, kudos were passed down
    No, kudos were not passed down. Kudos was passed down, since it is a singular noun in Greek that just happens to end in 's'.

    </nitpick>

    The plural of kudos is kudos.
    I see, now, that that usage has developed; apologies, Master Bowytz, if you were using it that way. (The notion that "kudos" is the plural of "kudo" (which is also becoming established) has spread far and wide, though...grumble, grumble...these kids need to get off my linguistic lawn!)

    Norman Diamond:
    Now what do we do about a developer who beats his brains out but who isn't Zaphod Beeblebrox?
    Maybe he's beating out his forebrain, midbrain, and hindbrain? <g>
  • (cs) in reply to GoatCheez
    GoatCheez:
    This is still a WTF. They should have used a sleep function. By NOT using a sleep function, while the application is waiting, it is pegging a CPU core at 100%. By using this form of a wait they are reducing the scalability of their application and increasing power usage. They should have used a sleep.

    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.

  • some twit (unregistered) in reply to anonymous
    anonymous:
    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.

    You can actually do this in Haskell.

  • David (unregistered) in reply to Ryan Fox

    TRWTF is the implementation using break instead of a simple for loop...

    $start = gettime(); for( $stop = $start; $stop-$start > $sec; $stop = gettime() );

  • urza9814 (unregistered) in reply to Damadar
    Damadar:
    Probably because that is taking a hammer to a problem that required a screwdriver.

    Code's easier to work with than re-clocking the CPU; can be done dynamically without fear, and doesn't affect any other programs that might be running on the server.

    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.

  • Ken B (unregistered) in reply to A Nerd With a View
    A Nerd With a View:
    I do my taxes every year using the TurboTax online site. There are a number of places where, after submitting some data, you're presented with a "status bar" that advances while you wait. It would display status messages like "checking your return for errors" and whatnot.
    I've seen that elsewhere, too. I remember buying a program to crack MS Word passwords: the actual crack was nearly instant. The developer flat-out said at some point that the status bar was added in to "make it seem like the program was doing something.
    That might be one of those "perceived values" situations. If it was a program you had to pay for, then if it could crack the password nearly instantaneously, it meant the program didn't really need to do much, and therefore shouldn't cost as much. (Or perhaps it should be free.)
  • Ken B (unregistered) in reply to MrMike
    MrMike:
    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 showing developers using our software how to use an index to help in record selection, they would get complaints from their clients. They were used to the reports taking several minutes to run, and when it ran almost instantaneously, they thought it didn't run, so they ran it again. And perhaps again. And then there would be multiple copies of the report waiting for them in the printer.

    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.

  • Ken B (unregistered) in reply to anonymous
    anonymous:
    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.

    "We already have a backup of next year's data. Restore the backup and fire all of our computer people."

    Economy collapses. Mass uprisings. World goes to war.

  • (cs) in reply to AD
    AD:
    Isn't there in PHP a sleep() function that won't consume the cpu introducing a wait? Even VB had it.
    Given that you used the past tense in "Even VB had it," I assume you're talking about "classic" VB (version 6 and earlier). In that case, no, VB didn't "have it," at least not in the sense that it was built in to the language. You had to call the Windows API Sleep() function directly.
  • hoot (unregistered) in reply to HonoredMule

    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.

  • Joe (unregistered)

    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...

  • ding (unregistered)

    http://php.net/manual/en/function.sleep.php

    hermm?

  • Deep (unregistered) in reply to GoatCheez

    +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.

  • Bones (unregistered)

    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.

  • venom (unregistered)

    Wow... I dont want to live on this planet anymore.

  • Cozzbie (unregistered) in reply to Gore

    Your comment is the Mother WTF of all WTF's

  • Cozzbie (unregistered) in reply to Gore

    Your comment is the Mother WTF of all WTF's

  • Arai (unregistered)

    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?

  • Ryno (unregistered)

    Visibility of system status is Nielsen's first design rule. The users should never wonder if a change was saved.

  • Ryno (unregistered)

    "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.

Leave a comment on “The Slow Down Loop”

Log In or post as a guest

Replying to comment #:

« Return to Article