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

commits at source.squeak.org commits at source.squeak.org
Wed Apr 29 23:51:55 UTC 2020


Chris Muller uploaded a new version of Chronology-Core to project The Inbox:
http://source.squeak.org/inbox/Chronology-Core-cmm.53.mcz

==================== Summary ====================

Name: Chronology-Core-cmm.53
Author: cmm
Time: 29 April 2020, 6:51:53.53317 pm
UUID: b930b208-c85e-4c6b-8254-2837493384bd
Ancestors: Chronology-Core-nice.52

- Extend the API to allow an integral representation of DateAndTime's, by introducing

	DateAndTime class>>#fromMicroseconds:
	DateAndTime>>#asMicroseconds

which go along with the existing API:

	DateAndTime class>>#fromSeconds:
	DateAndTime>>#asSeconds

- Every Squeak with the substring "utcMicrosecond" in the selector name refers to the number of microseconds since the POSIX epoch (1/1/1971 at 00:00:00.000), __except for one__:  Time utcMicroseconds.  Therefore, to avoid astonishment when using it with the "utc" API of DateAndTime, rename it without the "utc" prefix.

=============== Diff against Chronology-Core-nice.52 ===============

Item was added:
+ ----- Method: DateAndTime class>>fromMicroseconds: (in category 'smalltalk-80') -----
+ fromMicroseconds: anInteger 
+ 	"Answer a DateAndTime anInteger microseconds since the Squeak epoch: 1 January 1901."
+ 	^ self
+ 		utcMicroseconds: anInteger - (self epochOffset * 1000000)
+ 		offset: self localOffsetSeconds!

Item was added:
+ ----- Method: DateAndTime>>asMicroseconds (in category 'smalltalk-80') -----
+ asMicroseconds
+ 	"Return the number of microseconds since the Squeak epoch, 1/1/1901 @ 00:00:00."
+ 	^ utcMicroseconds + self class epochOffsetMicros!

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 microsecondClock + 200.
+ 	[Time microsecondClock >= t0] whileFalse.
- 	t0 := Time utcMicrosecondClock + 200.
- 	[Time utcMicrosecondClock >= t0] whileFalse.
  	t1 := self highResClock.
+ 	[Time microsecondClock >= (t0 + 10000)] whileFalse.
+ 	t1 := self highResClock - t1 * 1000 // (Time microsecondClock - 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 microsecondClock + 200.
+ 	[Time microsecondClock >= t0] whileFalse.
- 	t0 := Time utcMicrosecondClock + 200.
- 	[Time utcMicrosecondClock >= t0] whileFalse.
  	t2 := self highResClock.
+ 	[Time microsecondClock >= (t0 + 20000)] whileFalse.
+ 	t2 := self highResClock - t2 * 1000 // (Time microsecondClock - 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 microsecondClock + 200.
+ 	[Time microsecondClock >= t0] whileFalse.
- 	t0 := Time utcMicrosecondClock + 200.
- 	[Time utcMicrosecondClock >= t0] whileFalse.
  	t3 := self highResClock.
+ 	[Time microsecondClock >= (t0 + 30000)] whileFalse.
+ 	t3 := self highResClock - t3 * 1000 // (Time microsecondClock - 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 changed:
  ----- Method: Time class>>localMicrosecondClock (in category 'clock') -----
  localMicrosecondClock
  	"Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century).
  	 The value is derived from the current UTC wallclock time and the image's current notion of time zone."
+ 	^self microsecondClock + (DateAndTime localOffset asSeconds * 1000000)!
- 	^self utcMicrosecondClock + (DateAndTime localOffset asSeconds * 1000000)!

Item was added:
+ ----- Method: Time class>>microsecondClock (in category 'clock') -----
+ microsecondClock
+ 	"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!

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 microsecondClock.
- 	startUsecs := self utcMicrosecondClock.
  	timedBlock value.
+ 	^self microsecondClock - startUsecs!
- 	^self utcMicrosecondClock - startUsecs!

Item was changed:
  ----- Method: Time class>>millisecondClockValue (in category 'general inquiries') -----
  millisecondClockValue
  	"Answer the value of the millisecond clock."
  
+ 	^self microsecondClock // 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 microsecondClock.
- 	startUsecs := self utcMicrosecondClock.
  	timedBlock value.
+ 	^self microsecondClock - startUsecs * 1000!
- 	^self utcMicrosecondClock - startUsecs * 1000!

Item was added:
+ ----- Method: Time class>>totalMicroSeconds (in category 'smalltalk-80') -----
+ totalMicroSeconds
+ 	"Answer the total seconds since the Squeak epoch: 1 January 1901, in local time."
+ 
+ 	^self localMicrosecondClock // 1000000!

Item was changed:
  ----- 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>
+ self deprecated: 'Use #microsecondClock'.
  	^0!



More information about the Squeak-dev mailing list