[squeak-dev] The Inbox: Chronology-Core-mt.50.mcz

David T. Lewis lewis at mail.msen.com
Sat Nov 2 15:15:42 UTC 2019


+1 for inclusion, with the following suggested tweak:

Use printShowingMaxDecimalPlaces: rather than roundTo: in the percent
GC display, and also drop the space before the $%. Thus the last line
of the method would be:


  pair second } ]), (' {1}% GC time.' format: {gcTime / elapsedTime * 100 printShowingMaxDecimalPlaces: 5})


Rationale: Rounding may not do what you expect with some float calculations.
This may be VM dependent (I can explain in a separate follow up message),
but for example I saw occasional results like this:

 '85,200 per second. 11.7 microseconds per run. 2.3850000000000002 % GC time.'

Using printShowingMaxDecimalPlaces: will ensure this instead:

 '85,200 per second. 11.7 microseconds per run. 2.385% GC time.'

Dave


On Wed, Oct 30, 2019 at 11:13:41AM +0100, Tobias Pape wrote:
> We probably should introduce something like that
> 
> 
> gcTimings
> 
> 	^ (Smalltalk getVMParameters at: 8 "full") + 
> 		(Smalltalk getVMParameters at: 10 "incr")
> 
> 
> Best regards
> 	-Tobias
> > On 30.10.2019, at 10:27, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
> > 
> > [Error] bench
> >    '217,000,000 per second. 4.62 nanoseconds per run. 0.16 % GC time.'
> > [Error, Halt] bench
> >    '10,400,000 per second. 96.5 nanoseconds per run. 6.2 % GC time.'
> > [Error, Halt, Warning] bench
> >    '9,800,000 per second. 102 nanoseconds per run. 7.78 % GC time.'
> > 
> > Best,
> > Marcel
> >> Am 30.10.2019 10:25:21 schrieb commits at source.squeak.org <commits at source.squeak.org>:
> >> 
> >> A new version of Chronology-Core was added to project The Inbox:
> >> http://source.squeak.org/inbox/Chronology-Core-mt.50.mcz
> >> 
> >> ==================== Summary ====================
> >> 
> >> Name: Chronology-Core-mt.50
> >> Author: mt
> >> Time: 30 October 2019, 10:25:14.294226 am
> >> UUID: f064aadc-0e62-174e-b97c-f70cc22a23f6
> >> Ancestors: Chronology-Core-mt.49
> >> 
> >> Proposal to add GC pressure to #bench method.
> >> 
> >> =============== Diff against Chronology-Core-mt.49 ===============
> >> 
> >> Item was changed:
> >> ----- Method: BlockClosure>>benchFor: (in category '*chronology-core') -----
> >> 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 gcStart gcTime |
> >> - | 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.
> >> + Smalltalk garbageCollect.
> >> [ delay wait. shouldRun := false ] forkAt: Processor timingPriority - 1.
> >> startTime := Time millisecondClockValue.
> >> + gcStart := (Smalltalk vmParameterAt: 8) + (Smalltalk vmParameterAt: 10).
> >> [ shouldRun ] whileTrue: [ 
> >> self value.
> >> count := count + 1 ].
> >> elapsedTime := Time millisecondsSince: startTime.
> >> + gcTime := (Smalltalk vmParameterAt: 8) + (Smalltalk vmParameterAt: 10) - gcStart.
> >> ^(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 } ]), (' {1} % GC time.' format: {gcTime / elapsedTime * 100 roundTo: 0.0001})!
> >> - pair second } ])!
> >> 
> >> 
> > 
> 
> 
> 


More information about the Squeak-dev mailing list