[squeak-dev] The Inbox: Chronology-Core-cmm.56.mcz

Chris Muller asqueaker at gmail.com
Mon May 4 23:52:30 UTC 2020


Hi Levente,

This trades the "posix" nomenclature in the API for
#microsecondClockValue.  "Posix" is a private matter to
Chronology's implementation that should not be exposed in the API.

 - Chris


On Mon, May 4, 2020 at 6:42 PM <commits at source.squeak.org> wrote:

> Chris Muller uploaded a new version of Chronology-Core to project The
> Inbox:
> http://source.squeak.org/inbox/Chronology-Core-cmm.56.mcz
>
> ==================== Summary ====================
>
> Name: Chronology-Core-cmm.56
> Author: cmm
> Time: 4 May 2020, 6:42:27.516151 pm
> UUID: 3c97bedc-c192-4872-b0f2-e93199f506ce
> Ancestors: Chronology-Core-ul.54
>
> Building on Chronology-Core-ul.54:
>
> - Let #microsecondClockValue complement #millisecondClockValue, to offer
> higher precision.
> - New constructor, DateAndTime class>>#utcMicroseconds:, complements the
> above.
> - Make Time class>>#utcMicrosecondClock private to help avoid accidental
> improper use with the above.
>
> =============== Diff against Chronology-Core-ul.54 ===============
>
> Item was added:
> + ----- Method: DateAndTime class>>microsecondClockValue (in category
> 'smalltalk-80') -----
> + microsecondClockValue
> +       ^ self clock microsecondClockValue!
>
> Item was added:
> + ----- Method: DateAndTime class>>utcMicroseconds: (in category 'instance
> creation') -----
> + utcMicroseconds: microsecondClockValue
> +       "Instantiate a DateAndTime in UTC from the value of my
> #microsecondClockValue."
> +       ^ super new
> +               utcMicroseconds: microsecondClockValue
> +               offset: 0!
>
> Item was changed:
>   ----- Method: Time class>>estimateHighResClockTicksPerMillisecond (in
> category 'clock') -----
>   estimateHighResClockTicksPerMillisecond
>
>         | t0 t1 t2 t3 |
>
>         "Count the ticks ellapsed during a 10ms busy loop"
> +       t0 := Time microsecondClockValue + 200.
> +       [Time microsecondClockValue >= t0] whileFalse.
> -       t0 := Time utcMicrosecondClock + 200.
> -       [Time utcMicrosecondClock >= t0] whileFalse.
>         t1 := self highResClock.
> +       [Time microsecondClockValue >= (t0 + 10000)] whileFalse.
> +       t1 := self highResClock - t1 * 1000 // (Time microsecondClockValue
> - t0).
> -       [Time utcMicrosecondClock >= (t0 + 10000)] whileFalse.
> -       t1 := self highResClock - t1 * 1000 // (Time utcMicrosecondClock -
> t0).
>
>         "Count the ticks ellapsed during a 20ms busy loop"
> +       t0 := Time microsecondClockValue + 200.
> +       [Time microsecondClockValue >= t0] whileFalse.
> -       t0 := Time utcMicrosecondClock + 200.
> -       [Time utcMicrosecondClock >= t0] whileFalse.
>         t2 := self highResClock.
> +       [Time microsecondClockValue >= (t0 + 20000)] whileFalse.
> +       t2 := self highResClock - t2 * 1000 // (Time microsecondClockValue
> - t0).
> -       [Time utcMicrosecondClock >= (t0 + 20000)] whileFalse.
> -       t2 := self highResClock - t2 * 1000 // (Time utcMicrosecondClock -
> t0).
>
>         "Count the ticks ellapsed during a 30ms busy loop"
> +       t0 := Time microsecondClockValue + 200.
> +       [Time microsecondClockValue >= t0] whileFalse.
> -       t0 := Time utcMicrosecondClock + 200.
> -       [Time utcMicrosecondClock >= t0] whileFalse.
>         t3 := self highResClock.
> +       [Time microsecondClockValue >= (t0 + 30000)] whileFalse.
> +       t3 := self highResClock - t3 * 1000 // (Time microsecondClockValue
> - t0).
> -       [Time utcMicrosecondClock >= (t0 + 30000)] whileFalse.
> -       t3 := self highResClock - t3 * 1000 // (Time utcMicrosecondClock -
> t0).
>
>         "Take the median of the 3 estimates as the best"
>         ^ t1 <= t2
>                 ifTrue: [t2 <= t3
>                                 ifTrue: [t2]
>                                 ifFalse: [t1 <= t3
>                                                 ifTrue: [t3]
>                                                 ifFalse: [t1]]]
>                 ifFalse: [t1 <= t3
>                                 ifTrue: [t1]
>                                 ifFalse: [t2 <= t3
>                                                 ifTrue: [t3]
>                                                 ifFalse: [t2]]]!
>
> Item was added:
> + ----- Method: Time class>>microsecondClockValue (in category 'general
> inquiries') -----
> + microsecondClockValue
> +       "Answer the value of the microsecond clock, the number of
> microseconds elapsed since 1/1/1901 @ 00:00:00."
> +       ^ self utcMicrosecondClock -
> MicrosecondsBetweenPosixEpochAndSqueakEpoch!
>
> Item was changed:
>   ----- Method: Time class>>microsecondsToRun: (in category 'general
> inquiries') -----
>   microsecondsToRun: timedBlock
>         "Answer the number of microseconds timedBlock takes to return its
> value."
>
>         | startUsecs |
>         (self useHighResClockForTiming and: [self highResClock ~= 0])
>                 ifTrue: [       ^(self nanosecondsToRunHighRes:
> timedBlock) + 500 // 1000].
> +       startUsecs := self microsecondClockValue.
> -       startUsecs := self utcMicrosecondClock.
>         timedBlock value.
> +       ^self microsecondClockValue - startUsecs!
> -       ^self utcMicrosecondClock - startUsecs!
>
> Item was changed:
>   ----- Method: Time class>>millisecondClockValue (in category 'general
> inquiries') -----
>   millisecondClockValue
>         "Answer the value of the millisecond clock."
> +       ^self microsecondClockValue // 1000!
> -
> -       ^self utcMicrosecondClock // 1000!
>
> Item was changed:
>   ----- Method: Time class>>nanosecondsToRun: (in category 'general
> inquiries') -----
>   nanosecondsToRun: timedBlock
>         "Answer the number of nanoseconds timedBlock takes to return its
> value.
>         Use high resolution clock if available and preferred."
>
>         | startUsecs |
>         (self useHighResClockForTiming and: [self highResClock ~= 0])
>                 ifTrue: [       ^(self nanosecondsToRunHighRes:
> timedBlock)].
>         "Fallback to microseconds clock"
> +       startUsecs := self microsecondClockValue.
> -       startUsecs := self utcMicrosecondClock.
>         timedBlock value.
> +       ^self microsecondClockValue - startUsecs * 1000!
> -       ^self utcMicrosecondClock - startUsecs * 1000!
>
> Item was removed:
> - ----- Method: Time class>>posixUtcMicrosecondClock (in category 'clock')
> -----
> - posixUtcMicrosecondClock
> -       "Answer the UTC microseconds since the POSIX epoch (January 1st
> 1970 00:00:00 UTC)."
> -
> -       ^self utcMicrosecondClock -
> MicrosecondsBetweenPosixEpochAndSqueakEpoch!
>
> Item was changed:
> + ----- Method: Time class>>utcMicrosecondClock (in category 'private')
> -----
> - ----- Method: Time class>>utcMicrosecondClock (in category 'clock') -----
>   utcMicrosecondClock
>         "Answer the UTC microseconds since the Smalltalk epoch (January
> 1st 1901, the start of the 20th century).
>          The value is derived from the Posix epoch with a constant offset
> corresponding to elapsed microseconds
>          between the two epochs according to RFC 868."
>         <primitive: 240>
>         ^0!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200504/61dfffc9/attachment.html>


More information about the Squeak-dev mailing list