<div dir="ltr">Hi Levente,<div><br></div><div>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.</div><div><div><div><br></div><div> - Chris<br><div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 4, 2020 at 6:42 PM <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Chris Muller uploaded a new version of Chronology-Core to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Chronology-Core-cmm.56.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Chronology-Core-cmm.56.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Chronology-Core-cmm.56<br>
Author: cmm<br>
Time: 4 May 2020, 6:42:27.516151 pm<br>
UUID: 3c97bedc-c192-4872-b0f2-e93199f506ce<br>
Ancestors: Chronology-Core-ul.54<br>
<br>
Building on Chronology-Core-ul.54:<br>
<br>
- Let #microsecondClockValue complement #millisecondClockValue, to offer higher precision.<br>
- New constructor, DateAndTime class>>#utcMicroseconds:, complements the above.<br>
- Make Time class>>#utcMicrosecondClock private to help avoid accidental improper use with the above.<br>
<br>
=============== Diff against Chronology-Core-ul.54 ===============<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTime class>>microsecondClockValue (in category 'smalltalk-80') -----<br>
+ microsecondClockValue<br>
+ ^ self clock microsecondClockValue!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTime class>>utcMicroseconds: (in category 'instance creation') -----<br>
+ utcMicroseconds: microsecondClockValue<br>
+ "Instantiate a DateAndTime in UTC from the value of my #microsecondClockValue."<br>
+ ^ super new<br>
+ utcMicroseconds: microsecondClockValue<br>
+ offset: 0!<br>
<br>
Item was changed:<br>
----- Method: Time class>>estimateHighResClockTicksPerMillisecond (in category 'clock') -----<br>
estimateHighResClockTicksPerMillisecond<br>
<br>
| t0 t1 t2 t3 |<br>
<br>
"Count the ticks ellapsed during a 10ms busy loop"<br>
+ t0 := Time microsecondClockValue + 200.<br>
+ [Time microsecondClockValue >= t0] whileFalse.<br>
- t0 := Time utcMicrosecondClock + 200.<br>
- [Time utcMicrosecondClock >= t0] whileFalse.<br>
t1 := self highResClock.<br>
+ [Time microsecondClockValue >= (t0 + 10000)] whileFalse.<br>
+ t1 := self highResClock - t1 * 1000 // (Time microsecondClockValue - t0).<br>
- [Time utcMicrosecondClock >= (t0 + 10000)] whileFalse.<br>
- t1 := self highResClock - t1 * 1000 // (Time utcMicrosecondClock - t0).<br>
<br>
"Count the ticks ellapsed during a 20ms busy loop"<br>
+ t0 := Time microsecondClockValue + 200.<br>
+ [Time microsecondClockValue >= t0] whileFalse.<br>
- t0 := Time utcMicrosecondClock + 200.<br>
- [Time utcMicrosecondClock >= t0] whileFalse.<br>
t2 := self highResClock.<br>
+ [Time microsecondClockValue >= (t0 + 20000)] whileFalse.<br>
+ t2 := self highResClock - t2 * 1000 // (Time microsecondClockValue - t0).<br>
- [Time utcMicrosecondClock >= (t0 + 20000)] whileFalse.<br>
- t2 := self highResClock - t2 * 1000 // (Time utcMicrosecondClock - t0).<br>
<br>
"Count the ticks ellapsed during a 30ms busy loop"<br>
+ t0 := Time microsecondClockValue + 200.<br>
+ [Time microsecondClockValue >= t0] whileFalse.<br>
- t0 := Time utcMicrosecondClock + 200.<br>
- [Time utcMicrosecondClock >= t0] whileFalse.<br>
t3 := self highResClock.<br>
+ [Time microsecondClockValue >= (t0 + 30000)] whileFalse.<br>
+ t3 := self highResClock - t3 * 1000 // (Time microsecondClockValue - t0).<br>
- [Time utcMicrosecondClock >= (t0 + 30000)] whileFalse.<br>
- t3 := self highResClock - t3 * 1000 // (Time utcMicrosecondClock - t0).<br>
<br>
"Take the median of the 3 estimates as the best"<br>
^ t1 <= t2<br>
ifTrue: [t2 <= t3<br>
ifTrue: [t2]<br>
ifFalse: [t1 <= t3<br>
ifTrue: [t3]<br>
ifFalse: [t1]]]<br>
ifFalse: [t1 <= t3<br>
ifTrue: [t1]<br>
ifFalse: [t2 <= t3<br>
ifTrue: [t3]<br>
ifFalse: [t2]]]!<br>
<br>
Item was added:<br>
+ ----- Method: Time class>>microsecondClockValue (in category 'general inquiries') -----<br>
+ microsecondClockValue<br>
+ "Answer the value of the microsecond clock, the number of microseconds elapsed since 1/1/1901 @ 00:00:00."<br>
+ ^ self utcMicrosecondClock - MicrosecondsBetweenPosixEpochAndSqueakEpoch!<br>
<br>
Item was changed:<br>
----- Method: Time class>>microsecondsToRun: (in category 'general inquiries') -----<br>
microsecondsToRun: timedBlock <br>
"Answer the number of microseconds timedBlock takes to return its value."<br>
<br>
| startUsecs |<br>
(self useHighResClockForTiming and: [self highResClock ~= 0])<br>
ifTrue: [ ^(self nanosecondsToRunHighRes: timedBlock) + 500 // 1000].<br>
+ startUsecs := self microsecondClockValue.<br>
- startUsecs := self utcMicrosecondClock.<br>
timedBlock value.<br>
+ ^self microsecondClockValue - startUsecs!<br>
- ^self utcMicrosecondClock - startUsecs!<br>
<br>
Item was changed:<br>
----- Method: Time class>>millisecondClockValue (in category 'general inquiries') -----<br>
millisecondClockValue<br>
"Answer the value of the millisecond clock."<br>
+ ^self microsecondClockValue // 1000!<br>
- <br>
- ^self utcMicrosecondClock // 1000!<br>
<br>
Item was changed:<br>
----- Method: Time class>>nanosecondsToRun: (in category 'general inquiries') -----<br>
nanosecondsToRun: timedBlock<br>
"Answer the number of nanoseconds timedBlock takes to return its value.<br>
Use high resolution clock if available and preferred."<br>
<br>
| startUsecs |<br>
(self useHighResClockForTiming and: [self highResClock ~= 0])<br>
ifTrue: [ ^(self nanosecondsToRunHighRes: timedBlock)].<br>
"Fallback to microseconds clock"<br>
+ startUsecs := self microsecondClockValue.<br>
- startUsecs := self utcMicrosecondClock.<br>
timedBlock value.<br>
+ ^self microsecondClockValue - startUsecs * 1000!<br>
- ^self utcMicrosecondClock - startUsecs * 1000!<br>
<br>
Item was removed:<br>
- ----- Method: Time class>>posixUtcMicrosecondClock (in category 'clock') -----<br>
- posixUtcMicrosecondClock<br>
- "Answer the UTC microseconds since the POSIX epoch (January 1st 1970 00:00:00 UTC)."<br>
- <br>
- ^self utcMicrosecondClock - MicrosecondsBetweenPosixEpochAndSqueakEpoch!<br>
<br>
Item was changed:<br>
+ ----- Method: Time class>>utcMicrosecondClock (in category 'private') -----<br>
- ----- Method: Time class>>utcMicrosecondClock (in category 'clock') -----<br>
utcMicrosecondClock<br>
"Answer the UTC microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century).<br>
The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds<br>
between the two epochs according to RFC 868."<br>
<primitive: 240><br>
^0!<br>
<br>
<br>
</blockquote></div>