- 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
(The problem wasn't just the amusing code, but the reason why the code existed in the first place.)
Honestly, the real thing that's worse than failure is being sad enough that you have to whine and cry and squeal about how the stories here don't satisfy one's personal quality standard. There's, apparantly, quite a few people who make mere failures look good.
Admin
Exactly!
The fact that he is using .NET means the applications are running on a Windows platform (duh...) -
Why in all that is holy would you move an application from Unix/*nix to Windows?
If you wrote your Perl portably, you can install the Windows build of Perl (ActiveState has a nice binary you can load easily - or you can build from source if you are particularly masochistic) and run it on Windows without making changes to your code.
This, of course, assumes that it wasn't already on Windows to begin with....but if Perl was running on Windows to begin with, then why move your scripts to .NET!!?
This smells fishy.
Captcha: ewww My sentiments exactly.
Admin
Admin
The difference is his version, takes 100% CPU time doing nothing, which could otherwise be spent on more important jobs (like serving requests).
The built in Sleep function interacts with the kernel, and stops the whole thread running until time has elapsed (well that's how its implemented on a UNIX environment).
Admin
Admin
or drinking coffee out of that same tired mug continually complaining about how many servers they have to support, the number of tickets that were submitted yesterday, and the 8 million reasons he can't get your firewall port opened in dev sometime before 2010.
Admin
above post srry
lrn2BBCode
Admin
DateTime.Now.TimeOfDay is a TimeSpan object. But if he wanted the current time, then DateTime.Now would have sufficed, it being a DateTime object. Very WTF.
Admin
I think we should get ON his back... this is how is easy he could have gotten the Right answer... http://www.google.com.au/search?hl=en&q=How+to+sleep+a+thread+in+.net&meta=
Admin
Hey, if you're not going to:
a) Bitch about how stupid this person is b) Provide an even worse implementation c) Make another stupid comment about the name change of the site d) Begin your sentence with "The real WTF is..."
then you can move along.
Plausible explanations have no purpose on this site, sir!
Admin
Admin
By the way, I'm not the Sam who commented earlier in this thread. I'm the Sam who gloats about not telling you what my CAPTCHA is. Muhahaha! Damn, that's why you should never gloat...
Admin
Oh come on! Clearly this code was meant to be part of a load-testing system. You would run the CPU for different lengths of time at 100%, and measure how long it took for the CPU to overheat, thus providing you with a baseline thermal curve against which to tune your cooling systems. In fact, you could run this across an entire server farm to test the response of the air conditioning unit in the data center.
That's not difficult. Most windows programs and services stop on their own, randomly, using their own code.Admin
I wrote some Java that was nearly identical to this (except, you know, it was in Java) when I created a Power Hour buzzer in my freshman year of college. About 10 minutes into the event, the CPU fans would sound like jets preparing for takeoff.
I still have the source. I'm not sure why, but I feel compelled to post the relevant snippet:
CAPTCHA: This code is even shittier than Taco Bell tacos.
Admin
Okay, converting DateTime.Now.TimeOfDay to a string and back to a DateTime aside... I bet this code hiccups once a year: when it goes to sleep before "falling back" to DST and then wakes up before it went to sleep.
Admin
It's generally considered a "good practice" not to busy-loop your processor.
Admin
TimeSpan.FromSeconds is a static/shared function and therefore is not being instantiated
Admin
FromSeconds has to create a TimeSpan object to return.
Admin
Amen!
(The new name sucks:)
-RS
Admin
If he develops code that then gets put into production, then he is technically a developer, no matter his background. As such, he is eligible to have his code featured here.
I mean, why would we let people get away with writing wtf-y code just because they have the wrong background?
Admin
Admin
sleep(perl) takes seconds. sleep(CLR) takes milliseconds. What do you do when you say "sleep 20" and then it comes back pretty much instantly?
Admin
If most developers cannot even grasp multi-threading programming properly, how much does one expect an administrator to achieve?
Admin
Admin
This comment is overdue but I saw something just as bad in PL/SQL... sure customers complained, heads rolled, but the code was fixed to this psuedocode:
try to sleep... no? ok... while (timenow < timewewant){ <-- yes this is the actual code } success!!! yaaay!!!
So being in pl/sql, this would halt the customer's production server very severely... and since this was used in a "bussy" loop, something terribly terrible was on the horizon for my company!
Admin
OK, everyone missed the obvious reason he did it here.
He was made to change it to .NET against his own better judgement.
Later, they will complain about the performance of his script.
His reply: ".NET is much more resource intensive than Perl. When we did this in Perl it used almost no resources at all."
Captcha facilisi: He's hoping his reply will facilisi his being able to return to using his Perl scripts.