[Pharo-project] DateAndTime and TimeStamp precision

Miguel Enrique Cobá Martinez miguel.coba at gmail.com
Tue Feb 16 10:39:14 EST 2010


El mar, 16-02-2010 a las 14:39 +0100, Luc Fabresse escribió:
> Hi,
> 
>   I think it is related to: http://code.google.com/p/pharo/issues/detail?id=982
>   If I remember well, there is no primitive with nano second accuracy  
> so it is impossible to have it in real.

Yes, and indeed nano second accuracy is overkill for my current problem.
I only want some given precision so that

DateAndTime now < DateAndTime now

is always true, so that can be used to order events (object creation in
this case) using the date.

Thanks

> 
> Luc
> 
> Le 13 févr. 10 à 10:46, Stéphane Ducasse a écrit :
> 
> > Hi miguel
> >
> > what is the solution?
> > I remember that I saw passing some code to support nanos
> > but I'm not sure that it was integrated.
> > Now let us fix it if possible.
> >
> > Stef
> >
> > On Feb 13, 2010, at 1:32 AM, Miguel Enrique Cobá Martinez wrote:
> >
> >> 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
> >>
> >>
> >> _______________________________________________
> >> 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
> 
> 
> _______________________________________________
> 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