de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 getTime accuracy (decimal places)?
PostPosted: Wed Jul 13, 2016 12:27 pm 
Offline
Veteran
User avatar
I'm using getTime in a new script and was curious how precise the values it returns are.

When I use the following:
Code:
def timestamp = getTime()
def option = getBoolean("Pick an option, but be quick!","Option 1","Option 2")
def reaction = getTime() - timestamp
...
show("You chose "+option+" and responded in "+reaction+" seconds.")

... I notice that it seems to round to the nearest second. Example:
Code:
"You chose Option 2 and responded in 2 seconds."

Is there a way to use getTime (or an alternative) to get a more precise result like:
Code:
"You chose Option 2 and responded in 1.43 seconds."

Am I missing something easy or does getTime only round to the nearest second?


Top
 Profile Send private message 
 
 Re: getTime accuracy (decimal places)?
PostPosted: Wed Jul 13, 2016 2:04 pm 
Offline
Site Admin
User avatar
Yes getTime() is the simple way, returning an integer (rounded).

If you want some milliseconds instead of seconds, back to standard Groovy with "new Date().getTime()"
Code:
def timestamp = new Date().getTime()
def option = getBoolean("Pick an option, but be quick!","Option 1","Option 2")
def reaction = new Date().getTime() - timestamp
...
show("You chose "+option+" and responded in "+reaction+" milliseconds.")


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.