Energi consumption difference

Everything else that doesn't fall into one of the other PB categories.
oftit
User
User
Posts: 52
Joined: Sun Apr 25, 2010 5:08 am

Energi consumption difference

Post by oftit »

Hi all

Does the computer use more energy by connecting to the internet and checking mails than doing delay()?
In code:

Code: Select all

Repeat
ConnectmailServer()
Check mails()
DisconnectMailServer()
ForEver

Vs.

Repeat
ConnectmailServer()
Check mails()
DisconnectMailServer()
Delay(10000)
ForEver
Which one consumes the most?

Thank you
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Energi consumption difference

Post by eesau »

The first one uses more CPU cycles and thus more energy.
oftit
User
User
Posts: 52
Joined: Sun Apr 25, 2010 5:08 am

Re: Energi consumption difference

Post by oftit »

Oh ok. Thank you.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: Energi consumption difference

Post by Joakim Christiansen »

eesau wrote:The first one uses more CPU cycles and thus more energy.
Not only that but it could cause a DoS on the mail server.

I would actually recommend running the code in a separate thread with a delay of one minute. Not that 10 seconds is bad, but when dealing with servers one should try to cause as little as possible traffic. If 1000 people were using a program to check the same mail server every 10 seconds that would be a total of 100 requests per second.
I like logic, hence I dislike humans but love computers.
Post Reply