Author Topic: Uptimes!  (Read 7558 times)

0 Members and 1 Guest are viewing this topic.

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Uptimes!
« Reply #15 on: January 03, 2006, 05:50:15 pm »
Quote
C:\Program Files\Microsoft Visual Studio\MyProjects\uptime\Debug>uptime
System uptime: 2 days, 13 hours, 18 minutes, 12.46 seconds.

Code: [Select]
#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
int miliseconds, seconds, minutes, hours, days;
miliseconds = GetTickCount();
seconds = miliseconds / (1000); seconds = seconds % 60;
minutes = miliseconds / (1000 * 60); minutes = minutes % 60;
hours   = miliseconds / (1000 * 60 * 60); hours   = hours % 24;
days    = miliseconds / (1000 * 60 * 60 * 24);
miliseconds = miliseconds % 100;

printf("System uptime: ");
printf("%u", days);        printf(" days, ");
printf("%u", hours);       printf(" hours, ");
printf("%u", minutes);     printf(" minutes, ");
printf("%u", seconds);     printf(".");
printf("%u", miliseconds); printf(" seconds.");

return 0;
}
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline zorm

  • Hero Member
  • *****
  • Posts: 591
    • View Profile
    • Zorm's Page
Re: Uptimes!
« Reply #16 on: January 03, 2006, 06:10:06 pm »
Quote
C:\Program Files\Microsoft Visual Studio\MyProjects\uptime\Debug>uptime
System uptime: 2 days, 13 hours, 18 minutes, 12.46 seconds.

Code: [Select]
#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
int miliseconds, seconds, minutes, hours, days;
miliseconds = GetTickCount();
seconds = miliseconds / (1000); seconds = seconds % 60;
minutes = miliseconds / (1000 * 60); minutes = minutes % 60;
hours   = miliseconds / (1000 * 60 * 60); hours   = hours % 24;
days    = miliseconds / (1000 * 60 * 60 * 24);
miliseconds = miliseconds % 100;

printf("System uptime: ");
printf("%u", days);        printf(" days, ");
printf("%u", hours);       printf(" hours, ");
printf("%u", minutes);     printf(" minutes, ");
printf("%u", seconds);     printf(".");
printf("%u", miliseconds); printf(" seconds.");

return 0;
}

That sucks because it will wrap at 49.7 days IIRC. Fix.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Uptimes!
« Reply #17 on: January 03, 2006, 06:11:45 pm »
Quote
C:\Program Files\Microsoft Visual Studio\MyProjects\uptime\Debug>uptime
System uptime: 2 days, 13 hours, 18 minutes, 12.46 seconds.

Code: [Select]
#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
int miliseconds, seconds, minutes, hours, days;
miliseconds = GetTickCount();
seconds = miliseconds / (1000); seconds = seconds % 60;
minutes = miliseconds / (1000 * 60); minutes = minutes % 60;
hours   = miliseconds / (1000 * 60 * 60); hours   = hours % 24;
days    = miliseconds / (1000 * 60 * 60 * 24);
miliseconds = miliseconds % 100;

printf("System uptime: ");
printf("%u", days);        printf(" days, ");
printf("%u", hours);       printf(" hours, ");
printf("%u", minutes);     printf(" minutes, ");
printf("%u", seconds);     printf(".");
printf("%u", miliseconds); printf(" seconds.");

return 0;
}

That sucks because it will wrap at 49.7 days IIRC. Fix.

Is there actually a way to get proper uptime on Windows?

Offline zorm

  • Hero Member
  • *****
  • Posts: 591
    • View Profile
    • Zorm's Page
Re: Uptimes!
« Reply #18 on: January 03, 2006, 06:16:27 pm »
Yes, using QueryPerformanceFrequency and QueryPerformanceCounter.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Uptimes!
« Reply #19 on: January 03, 2006, 06:30:10 pm »
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Ergot

  • 吴立峰 ^_^ !
  • x86
  • Hero Member
  • *****
  • Posts: 3724
  • I steal bandwidth. p_o
    • View Profile
Re: Uptimes!
« Reply #20 on: January 03, 2006, 06:35:03 pm »
Ironically, there was a power outage last night. :(
Pwned :( Did you save your essay :O?
Who gives a damn? I fuck sheep all the time.
And yes, male both ends.  There are a couple lesbians that need a two-ended dildo...My router just refuses to wear a strap-on.
(05:55:03) JoE ThE oDD: omfg good job i got a boner thinkin bout them chinese bitches
(17:54:15) Sidoh: I love cosmetology

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Uptimes!
« Reply #21 on: January 03, 2006, 07:13:10 pm »
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.

Hehe, that's how I check on Windows too.

Pwned :( Did you save your essay :O?

I did! :)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Uptimes!
« Reply #22 on: January 03, 2006, 07:27:44 pm »
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.

Hehe, that's how I check on Windows too.

Psh... who said anything about Windows?














OK, ok, I can't imagine going 84 days on Linux.  :o
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Quik

  • Webmaster Guy
  • x86
  • Hero Member
  • *****
  • Posts: 3262
  • \x51 \x75 \x69 \x6B \x5B \x78 \x38 \x36 \x5D
    • View Profile
Re: Uptimes!
« Reply #23 on: January 03, 2006, 07:33:39 pm »
Turned off my Linux server the other day for a day, before that it had 5 or 6 weeks going.
Quote
[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Uptimes!
« Reply #24 on: January 03, 2006, 07:42:05 pm »
Haha, I noticed deepthought is running quite a bit faster after the restart, even if it was accidental/unwanted. :)

Offline igimo1

  • Full Member
  • ***
  • Posts: 420
    • View Profile
Re: Uptimes!
« Reply #25 on: January 03, 2006, 08:04:51 pm »
System uptime: 2 days, 18 hours, 14 minutes, 38 seconds, and 828 milliseconds.

Offline skip

  • Full Member
  • ***
  • Posts: 387
  • mmk
    • View Profile
Re: Uptimes!
« Reply #26 on: January 03, 2006, 08:11:06 pm »
System uptime 15 days, 4 hours, 7 minutes and 32 seconds, connection uptime 3 days, 1 hours, 23 minutes and 49 seconds.

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: Uptimes!
« Reply #27 on: January 03, 2006, 08:33:05 pm »
LILI: [20:32:50.204] Computer Time: 13 days, 10 hours, 41 minutes, 31 seconds
Attic: [20:36:40.311] Computer Time: 24 minutes, 21 seconds
Paradise: Off
Laptop: Off

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Uptimes!
« Reply #28 on: January 03, 2006, 10:05:05 pm »
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.

Hehe, that's how I check on Windows too.

Psh... who said anything about Windows?

I don't think any other OS would require such a kludge. 

It's the same idea as finding a host's ip by pinging them.. stuff like that bugs me :)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Uptimes!
« Reply #29 on: January 03, 2006, 10:21:28 pm »
I don't think any other OS would require such a kludge. 
Note that I didn't say I would *check* it that way, I said I'd *notice* it.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.