The Trunk: Kernel-cmm.1238.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-cmm.1238.mcz

commits-2
Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.1238.mcz

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

Name: Kernel-cmm.1238
Author: cmm
Time: 25 May 2019, 5:30:44.220675 pm
UUID: e3efa7f8-adc8-434c-a1d2-7efeda6d0fca
Ancestors: Kernel-nice.1237

- Moved several methods belonging to Chronology to that package.

=============== Diff against Kernel-nice.1237 ===============

Item was removed:
- ----- Method: BlockClosure>>bench (in category 'evaluating') -----
- bench
- "See how many times I can value in 5 seconds.  I'll answer a meaningful description."
-
- ^self benchFor: 5 seconds!

Item was removed:
- ----- Method: BlockClosure>>benchFor: (in category 'evaluating') -----
- benchFor: aDuration
- "See how many times I can value within the given duration.  I'll answer a meaningful description."
-
- | startTime shouldRun count elapsedTime  roundTo3Digits delay |
- roundTo3Digits := [:num |
- | rounded lowDigit |
- rounded := (num * 1000) rounded. "round to 1/1000"
- lowDigit := (rounded numberOfDigitsInBase: 10) - 3. "keep only first 3 digits"
- rounded := rounded roundTo:(10 raisedTo: lowDigit).
- (lowDigit >= 3 or: [rounded \\ 1000 = 0]) "display fractional part only when needed"
- ifTrue: [(rounded // 1000) asStringWithCommas]
- ifFalse: [(rounded / 1000.0) printString]].
- delay := aDuration asDelay.
- count := 0.
- shouldRun := true.
- [ delay wait. shouldRun := false ] forkAt: Processor timingPriority - 1.
- startTime := Time millisecondClockValue.
- [ shouldRun ] whileTrue: [
- self value.
- count := count + 1 ].
- elapsedTime := Time millisecondsSince: startTime.
- ^(roundTo3Digits value: count * 1000 / elapsedTime) , ' per second.', ((
- #(
- (1e-3 'seconds')
- (1 'milliseconds')
- (1e3 'microseconds')
- (1e6 'nanoseconds')
- )
- detect: [ :pair | elapsedTime * pair first >= count ]
- ifNone: [ #(1e9 'picoseconds') ])
- in: [ :pair |
- ' {1} {2} per run.' format: {
- (roundTo3Digits value: elapsedTime * pair first / count).
- pair second } ])!

Item was removed:
- ----- Method: BlockClosure>>durationToRun (in category 'evaluating') -----
- durationToRun
- "Answer the duration taken before this block returns."
-
- ^ Time durationToRun: self
- !

Item was removed:
- ----- Method: BlockClosure>>timeToRun (in category 'evaluating') -----
- timeToRun
- "Answer the number of milliseconds taken to execute this block."
-
- ^ Time millisecondsToRun: self
- !

Item was removed:
- ----- Method: BlockClosure>>timeToRunWithoutGC (in category 'evaluating') -----
- timeToRunWithoutGC
- "Answer the number of milliseconds taken to execute this block without GC time."
-
- ^(Smalltalk vmParameterAt: 8) +
- (Smalltalk vmParameterAt: 10) +
- self timeToRun -
- (Smalltalk vmParameterAt: 8) -
- (Smalltalk vmParameterAt: 10)
- !

Item was removed:
- ----- Method: BlockClosure>>valueWithin:onTimeout: (in category 'evaluating') -----
- valueWithin: aDuration onTimeout: timeoutBlock
- "Evaluate the receiver.
- If the evaluation does not complete in less than aDuration evaluate the timeoutBlock instead"
-
- | theProcess delay watchdog tag |
-
- aDuration <= Duration zero ifTrue: [^ timeoutBlock value ].
-
- "the block will be executed in the current process"
- theProcess := Processor activeProcess.
- delay := aDuration asDelay.
- tag := self.
-
- "make a watchdog process"
- watchdog := [
- delay wait. "wait for timeout or completion"
- theProcess ifNotNil:[ theProcess signalException: (TimedOut new tag: tag)]
- ] newProcess.
-
- "Watchdog needs to run at high priority to do its job (but not at timing priority)"
- watchdog priority: Processor timingPriority-1.
-
- "catch the timeout signal"
- ^ [ watchdog resume. "start up the watchdog"
- self ensure:[ "evaluate the receiver"
- theProcess := nil. "it has completed, so ..."
- delay delaySemaphore signal. "arrange for the watchdog to exit"
- ]] on: TimedOut do: [ :e |
- e tag == tag
- ifTrue:[ timeoutBlock value ]
- ifFalse:[ e pass]].!

Item was removed:
- ----- Method: Integer>>asYear (in category 'converting') -----
- asYear
-
- ^ Year year: self
- !

Item was removed:
- ----- Method: Number>>asDuration (in category 'converting') -----
- asDuration
-
- ^ Duration nanoSeconds: self asInteger
- !

Item was removed:
- ----- Method: Number>>day (in category 'converting') -----
- day
-
- ^ self sign days!

Item was removed:
- ----- Method: Number>>days (in category 'converting') -----
- days
-
- ^ Duration days: self!

Item was removed:
- ----- Method: Number>>hour (in category 'converting') -----
- hour
-
- ^ self sign hours
- !

Item was removed:
- ----- Method: Number>>hours (in category 'converting') -----
- hours
-
- ^ Duration hours: self!

Item was removed:
- ----- Method: Number>>milliSecond (in category 'converting') -----
- milliSecond
-
- ^ self sign milliSeconds
- !

Item was removed:
- ----- Method: Number>>milliSeconds (in category 'converting') -----
- milliSeconds
-
- ^ Duration milliSeconds: self
- !

Item was removed:
- ----- Method: Number>>minute (in category 'converting') -----
- minute
-
- ^ self sign minutes
- !

Item was removed:
- ----- Method: Number>>minutes (in category 'converting') -----
- minutes
-
- ^ Duration minutes: self!

Item was removed:
- ----- Method: Number>>nanoSecond (in category 'converting') -----
- nanoSecond
-
- ^ self sign nanoSeconds
- !

Item was removed:
- ----- Method: Number>>nanoSeconds (in category 'converting') -----
- nanoSeconds
-
- ^ Duration nanoSeconds: self.!

Item was removed:
- ----- Method: Number>>second (in category 'converting') -----
- second
-
- ^ self sign seconds
- !

Item was removed:
- ----- Method: Number>>seconds (in category 'converting') -----
- seconds
-
- ^ Duration seconds: self!

Item was removed:
- ----- Method: Number>>week (in category 'converting') -----
- week
-
- ^ self sign weeks
- !

Item was removed:
- ----- Method: Number>>weeks (in category 'converting') -----
- weeks
-
- ^ Duration weeks: self!