Mon Oct 18, 2021 7:57 am
Login Register Lost Password? Contact Us


time with milliseconds

Questions around writing code and queries

Wed Jul 13, 2011 8:05 pm Change Time Zone

Hello! I see there is an attribute (ut.getTime()) which returns hrs/mins/secs. Is there an existing attribute which will return milliseconds?
Thanks!
champirs
 
Posts: 5
Joined: Fri May 13, 2011 8:10 pm

Thu Jul 14, 2011 9:59 am Change Time Zone

Try
import std.system.debug;

debug.msTick();

Beware that definitions aren't assignments, and because the function isn't pure it will tend to be re-evaluated each time it is used. This can lead to some confusing results if you're not careful. E.g.,

startTime := debug.msTick();
doSomethingComplex();
output(debug.msTick()-startTime);
Will typically output 0. startTime is evaluated at the same time as debug.msTick()!

Assigning startTime into a row, or using independent e.g.,

startTime := debug.msTick() : independent;

are some ways of avoiding this.


You need to be careful about when the expression is evaluated.
ghalliday
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 198
Joined: Wed May 18, 2011 9:48 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron