[squeak-dev] The Inbox: Chronology-Core-mt.51.mcz
Chris Muller
ma.chris.m at gmail.com
Tue Nov 12 23:25:46 UTC 2019
(Palm meets forehead. :) )
Still, not obvious what would be a good name. #asMetricDescription?
#printSiUnits?
And, actually, a more general function would seem to beg for more
configurability -- like full-name vs. abbreviation, as well the possibility
of specifying a precision.
I'll have to think about it, thanks...
On Tue, Nov 12, 2019 at 3:04 AM Marcel Taeumel <marcel.taeumel at hpi.de>
wrote:
> Heyho.
>
> > ... but I think extends even beyond "bytes descriptions" ...
>
> +1 The "bytes" domain is way too specific for this kind of functionality
>
> https://en.wikipedia.org/wiki/Metric_prefix
>
> Best,
> Marcel
>
> Am 12.11.2019 04:42:05 schrieb Chris Muller <asqueaker at gmail.com>:
> Hi guys,
>
> This looks like a lot of thought went into making an output that we want
> to be both functional as well as easy to read.
>
> On a similar topic, has anyone else been finding #asBytesDescription to be
> similarly useful for reporting integral quantities, when the top three
> orders of precision are enough? What I like about it is how it lets me
> express any integer all the way up to (2 raisedTo: 99) in no more than
> *four* characters. See?
>
> 9999 asBytesDescription "10k"
> (2 raisedTo: 99) asBytesDescription " '634Y' <--- Yotta's"
>
> This is a wonderfully dense representation, but I think extends even
> beyond "bytes descriptions" -- I think we need a better name for it... Is
> there a proper academic name for this representation?
>
> - Chris
>
>
> On Mon, Nov 11, 2019 at 4:40 AM <commits at source.squeak.org> wrote:
>
>> A new version of Chronology-Core was added to project The Inbox:
>> http://source.squeak.org/inbox/Chronology-Core-mt.51.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Chronology-Core-mt.51
>> Author: mt
>> Time: 11 November 2019, 11:40:16.217633 am
>> UUID: 199ad2ea-67cb-2545-84e9-4f24e577216f
>> Ancestors: Chronology-Core-mt.50
>>
>> Improve formatting for GC pressure as suggested by Dave.
>>
>> =============== Diff against Chronology-Core-mt.50 ===============
>>
>> 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 |
>> 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 printShowingMaxDecimalPlaces: 5})!
>> - pair second } ]), (' {1} % GC time.'
>> format: {gcTime / elapsedTime * 100 roundTo: 0.0001})!
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191112/99ead8d6/attachment.html>
More information about the Squeak-dev
mailing list
|