Author |
Message |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Mon Sep 19, 2005 7:55 pm Post subject: java eclapsed time. |
 |
|
|
|
I've looked around forever and i can't seem to get this right.
I want !buptime to display how long the bot has been up.
Lets Say:
BDwinsAlt> !buptime
ST 2.3> Bot up for 2 day(s) 11 hour(s) 10 second(s). [Since 09/19/2005 at 7:00]
Please help  |
|
Back to top |
|
 |
Contempt+ Server Help Squatter
Age:36 Gender: Joined: May 15 2005 Posts: 682 Location: Home Offline
|
Posted: Mon Sep 19, 2005 8:30 pm Post subject: |
 |
|
|
|
I was gonna start working on that one soon. Just gotta get around to doing it. I've got a lot of other stuff I'm working on at the same time, so I don't have the time to do it, lol. _________________ SSE Network Administrator |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Mon Sep 19, 2005 10:26 pm Post subject: |
 |
|
|
|
.
I bet it will be harder than you think. I've looked around but nothing gives me a good awnser.
Make a really cool bot and webiste then release it for public use.
I'm going to buy a book on java.
Anyone got suggestions?
tell me if http://bots.sscentral.com/bdwinsalt looks ok. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Mon Sep 19, 2005 10:54 pm Post subject: |
 |
|
|
|
That's really loud. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
|
Back to top |
|
 |
Donkano Server Help Squatter
Gender: Joined: Jul 02 2003 Posts: 763 Offline
|
Posted: Tue Sep 20, 2005 6:17 pm Post subject: |
 |
|
|
|
Contempt+ wrote: | I was gonna start working on that one soon. Just gotta get around to doing it. I've got a lot of other stuff I'm working on at the same time, so I don't have the time to do it, lol. |
Easy, just get the bot to do: ?usage
Then get it to return that string to the player requesting. |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Tue Sep 20, 2005 6:20 pm Post subject: |
 |
|
|
|
That's the most ugly solution, though, Donk. |
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Tue Sep 20, 2005 6:23 pm Post subject: |
 |
|
|
|
Yea, even Mervbot doesn't do it that way  _________________
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Sep 20, 2005 6:49 pm Post subject: |
 |
|
|
|
it also doesn't solve the problem, donk.
In general, I don't recommend coding if you have trouble spelling words, like the title of your topic. It just leads to syntax errors. |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Tue Sep 20, 2005 10:36 pm Post subject: |
 |
|
|
|
Did i ask you how to spell it?  |
|
Back to top |
|
 |
Contempt+ Server Help Squatter
Age:36 Gender: Joined: May 15 2005 Posts: 682 Location: Home Offline
|
Posted: Tue Sep 20, 2005 10:47 pm Post subject: |
 |
|
|
|
It might be hard, but you could get MERV's code for !uptime and see how they do it. Sure Java is different from C++, but you can at least get a basic idea, right? |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Wed Sep 21, 2005 12:13 am Post subject: |
 |
|
|
|
it's not a difficult algorithm
record time when the bot is started
when !uptime is called print out the difference in time. |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Wed Sep 21, 2005 8:10 am Post subject: |
 |
|
|
|
I just don't know how to record the time when the bot was started. That's where my probelm is. I know how to subtract time into days/hours/minutes now.
I just need that start time. |
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Wed Sep 21, 2005 8:53 am Post subject: |
 |
|
|
|
Quote: | public static long currentTimeMillis()
Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.
See the description of the class Date for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC). |
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Wed Sep 21, 2005 10:27 am Post subject: |
 |
|
|
|
I really wish java would have an option for comparing against the uptime of the system - not a clock. The system clock changes for various reasons, out of sync with UTC, daylight savings time, etc. With that issue imports an instability into the timer scheduler of Java - which I have already discussed. Had they used the uptime of the OS, it'll never go backwards, nor massively forward into the future. A bit more stable. :/ _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Wed Sep 21, 2005 9:01 pm Post subject: |
 |
|
|
|
Agreed. And i'll try and see if it lets me send the currentMillis ina private message. Last time it said it couldn't do somethign with int.
I dunno, ill figure it out. |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Thu Sep 22, 2005 3:05 am Post subject: |
 |
|
|
|
Cyph, you mean like System.currentTimeMillis()? _________________
 |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Sep 22, 2005 8:18 am Post subject: |
 |
|
|
|
System.currentTimeMillis() depends on the current system time, not the uptime of the OS. They also say a lot of 'beware' statements in the API about it.
Looking though,nanoTime() looks more or less what I think, I would use. the API states "Returns the current value of the most precise available system timer, in nanoseconds." - not sure. It has the guarantee of precision but not accuracy. :/
:shrug: |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Sep 22, 2005 10:13 am Post subject: |
 |
|
|
|
From what I've gathered, he's not concerned about OS uptime. Only finding bot uptime. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Sep 22, 2005 10:22 am Post subject: |
 |
|
|
|
I know that. But, the "elapsed" (current_time - old_time) time will change when daylight savings time, etc. occur, does it not?
That's why you need an independent timing system such as the uptime of the OS where it'll never go backwards/forwards based on any specific day (or time).
I feel this appropriate quote fits well:
"Time line?!?!? This is no time to argue about time! We don't HAVE the time! ... what was I saying?" -- Troi, Star Trek: First Contact.  |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Sep 22, 2005 12:30 pm Post subject: |
 |
|
|
|
technically 'yes', you "should" worry about it. |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Thu Sep 22, 2005 12:57 pm Post subject: |
 |
|
|
|
why? He wants a way to see if his bot is staying online for a long time.
It's not a life or death application, any effort to avoid things like daylight savings time is not worth the time spent implementing. |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Sep 22, 2005 1:48 pm Post subject: |
 |
|
|
|
I would think with a definition like "the number of milliseconds elapsed since 12:00, midnight, Jan 1 1970", that DST would already be factored in. I could be wrong, of course. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Sep 22, 2005 4:09 pm Post subject: |
 |
|
|
|
Seeing as a long will overflow in 49.7 days, I'd say using a GetTickCount-like function would be more reliable than this currentTimeMillis(). |
|
Back to top |
|
 |
|