[Pharo-project] DateAndTime and TimeStamp precision

Miguel Enrique Cobá Martinez miguel.coba at gmail.com
Fri Feb 12 19:32:14 EST 2010


El vie, 12-02-2010 a las 14:58 -0800, John M McIntosh escribió:
> With the Mac VM 5.4b1 I have a microsecond clock. 
> http://n4.nabble.com/microsecond-timing-for-GC-work-td1016253.html
> 
> zero feedback, maybe it's too fast and you never get above 1 millisecond in testing eh? 


Thanks that indeed shown a difference in my machine. 

But, then other question, why the default implementation of DateAndTime
now and TimeStamp now isn't smaller than a second.
By sending now I get a DateAndTime object but by sending
millesecondClockValue a get a SmallInteger representing the number of
milliseconds.

But there isn't in the class side of both classes and neither in Time
class a method to build a DateAndTime, a TimeStamp or a Time from
milliseconds. So to convert this value to a date again I will have to
trunk the time to a second resolution. Is this analysis correct?

Of course I could index my objects in the list with the millis number
but I would be happier if I could index them with a real date object.

Anyway, not that that is a show stopper, is just that when creating
objects I'm assigning a creation date and I would like to find what
objects are older that others created at about the same lapse, without
resorting to use their position in an external data structure (i.e. the
OrderedCollection, an array or the line number in a file).

Thanks to everyone for the answers.

> 
> 
> On 2010-02-12, at 12:46 PM, csrabak at bol.com.br wrote:
> 
> > Miguel,
> > 
> > Pharo allows you to drill down to millisecond resolution, but for your 'benchmark' that's still too coarse:
> > 
> > {DateAndTime. TimeStamp } collect: [ :class |
> > | list |
> > list := OrderedCollection new.
> > 1 to: 1000 do: [ :each |
> > value := class millisecondClockValue.
> > list add: value ].
> > list last - list first ].
> > 
> > I get an Array (1 1).
> > 
> > Changing from 1000 to 100000 (hundred fold) I got  #(77 141).
> > 
> > HTH
> > 
> > --
> > Cesar Rabak
> > 
> > Em 12/02/2010 17:02, Miguel Enrique Cobá Martinez < miguel.coba at gmail.com > escreveu:
> > I am noticing that both
> > 
> > DateAndTime now
> > TimeStamp now
> > 
> > have a precision of seconds, that is, the nanos is always 0.
> > 
> > I am doing a bulk data creation and inserting them in a list with a
> > timestamp for each insertion but this isn't working because several
> > entries have the very same DateAndTime or Timestamp.
> > 
> > For example:
> > 
> > {DateAndTime. TimeStamp } collect: [ :class |
> > | list |
> > list := OrderedCollection new.
> > 1 to: 1000 do: [ :each |
> > value := class now.
> > list add: value ].
> > list last - list first ]
> > 
> > gives an Array(0:00:00:00 0:00:00:00)
> > 
> > How can achieve smaller than a second timestamping in Pharo?
> > -- 
> > Miguel Cobá
> > http://miguel.leugim.com.mx
> > 
> > 
> > _______________________________________________
> > Pharo-project mailing list
> > Pharo-project at lists.gforge.inria.fr
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> > 
> > _______________________________________________
> > Pharo-project mailing list
> > Pharo-project at lists.gforge.inria.fr
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> 
> --
> ===========================================================================
> John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
> 
> 
> 
> 
> 
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

-- 
Miguel Cobá
http://miguel.leugim.com.mx





More information about the Pharo-dev mailing list