The Trunk: Kernel-nice.491.mcz

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

The Trunk: Kernel-nice.491.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.491.mcz

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

Name: Kernel-nice.491
Author: nice
Time: 10 September 2010, 2:33:29.294 pm
UUID: 00d7b4ff-5219-aa44-b82d-be4c7f18c761
Ancestors: Kernel-ar.490

Prevent bench to display 14 digits or so.
3 significative digits should be enough for a human brain (at least mine).

=============== Diff against Kernel-ar.490 ===============

Item was changed:
  ----- Method: BlockClosure>>bench (in category 'evaluating') -----
  bench
  "See how many times I can value in 5 seconds.  I'll answer a meaningful description."
 
+ | startTime endTime count roundTo3Digits |
+ roundTo3Digits := [:num | num roundTo: (10 raisedTo: (num numberOfDigitsInBase: 10) - 3)].
- | startTime endTime count |
  count := 0.
  endTime := Time millisecondClockValue + 5000.
  startTime := Time millisecondClockValue.
  [ Time millisecondClockValue > endTime ] whileFalse: [ self value.  count := count + 1 ].
  endTime := Time millisecondClockValue.
  ^count = 1
+ ifTrue: [ (roundTo3Digits value: (endTime - startTime) // 1000) printString, ' seconds.' ]
- ifTrue: [ ((endTime - startTime) // 1000) printString, ' seconds.' ]
  ifFalse:
+ [ ((roundTo3Digits value: (count * 1000 * 100) // (endTime - startTime)) / 100.0) printString, ' per second.' ]!
- [ ((count * 1000) / (endTime - startTime)) asFloat printString, ' per second.' ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.491.mcz

Chris Muller-3
Hi, I've been meaning to update this for a while too.  A comment and a question.

Re: displaying only 3 digits, isn't roundTo: 0.001 supposed to accomplish this?

Also, I am thinking that #bench should display the total time it took
to run the block if the block could only be run once in the
five-second limit.

IOW, how sensible is it for it to display:   '0.877 per second.'  ??

Probably, instead, it should just say, "4.123 seconds." shouldn't it?

(Again, this is only in the case where it could not run more than once
in 5 seconds).

 - Chris


On Fri, Sep 10, 2010 at 7:34 AM,  <[hidden email]> wrote:

> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-nice.491.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.491
> Author: nice
> Time: 10 September 2010, 2:33:29.294 pm
> UUID: 00d7b4ff-5219-aa44-b82d-be4c7f18c761
> Ancestors: Kernel-ar.490
>
> Prevent bench to display 14 digits or so.
> 3 significative digits should be enough for a human brain (at least mine).
>
> =============== Diff against Kernel-ar.490 ===============
>
> Item was changed:
>  ----- Method: BlockClosure>>bench (in category 'evaluating') -----
>  bench
>        "See how many times I can value in 5 seconds.  I'll answer a meaningful description."
>
> +       | startTime endTime count roundTo3Digits |
> +       roundTo3Digits := [:num | num roundTo: (10 raisedTo: (num numberOfDigitsInBase: 10) - 3)].
> -       | startTime endTime count |
>        count := 0.
>        endTime := Time millisecondClockValue + 5000.
>        startTime := Time millisecondClockValue.
>        [ Time millisecondClockValue > endTime ] whileFalse: [ self value.  count := count + 1 ].
>        endTime := Time millisecondClockValue.
>        ^count = 1
> +               ifTrue: [ (roundTo3Digits value: (endTime - startTime) // 1000) printString, ' seconds.' ]
> -               ifTrue: [ ((endTime - startTime) // 1000) printString, ' seconds.' ]
>                ifFalse:
> +                       [ ((roundTo3Digits value: (count * 1000 * 100) // (endTime - startTime)) / 100.0) printString, ' per second.' ]!
> -                       [ ((count * 1000) / (endTime - startTime)) asFloat printString, ' per second.' ]!
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.491.mcz

Nicolas Cellier
The problem is for micro benchmarks where the display is more like

1.40983424386e6 per second

so roundTo: 0.001 does not solve anything (the last digits are not
meaningfull at all).
Using three digits, I get

1.41e6 per second

which is already better (less pollution).

For the other suggestions, I don't know, just did the simplest modification...

Nicolas


2010/9/10 Chris Muller <[hidden email]>:

> Hi, I've been meaning to update this for a while too.  A comment and a question.
>
> Re: displaying only 3 digits, isn't roundTo: 0.001 supposed to accomplish this?
>
> Also, I am thinking that #bench should display the total time it took
> to run the block if the block could only be run once in the
> five-second limit.
>
> IOW, how sensible is it for it to display:   '0.877 per second.'  ??
>
> Probably, instead, it should just say, "4.123 seconds." shouldn't it?
>
> (Again, this is only in the case where it could not run more than once
> in 5 seconds).
>
>  - Chris
>
>
> On Fri, Sep 10, 2010 at 7:34 AM,  <[hidden email]> wrote:
>> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
>> http://source.squeak.org/trunk/Kernel-nice.491.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-nice.491
>> Author: nice
>> Time: 10 September 2010, 2:33:29.294 pm
>> UUID: 00d7b4ff-5219-aa44-b82d-be4c7f18c761
>> Ancestors: Kernel-ar.490
>>
>> Prevent bench to display 14 digits or so.
>> 3 significative digits should be enough for a human brain (at least mine).
>>
>> =============== Diff against Kernel-ar.490 ===============
>>
>> Item was changed:
>>  ----- Method: BlockClosure>>bench (in category 'evaluating') -----
>>  bench
>>        "See how many times I can value in 5 seconds.  I'll answer a meaningful description."
>>
>> +       | startTime endTime count roundTo3Digits |
>> +       roundTo3Digits := [:num | num roundTo: (10 raisedTo: (num numberOfDigitsInBase: 10) - 3)].
>> -       | startTime endTime count |
>>        count := 0.
>>        endTime := Time millisecondClockValue + 5000.
>>        startTime := Time millisecondClockValue.
>>        [ Time millisecondClockValue > endTime ] whileFalse: [ self value.  count := count + 1 ].
>>        endTime := Time millisecondClockValue.
>>        ^count = 1
>> +               ifTrue: [ (roundTo3Digits value: (endTime - startTime) // 1000) printString, ' seconds.' ]
>> -               ifTrue: [ ((endTime - startTime) // 1000) printString, ' seconds.' ]
>>                ifFalse:
>> +                       [ ((roundTo3Digits value: (count * 1000 * 100) // (endTime - startTime)) / 100.0) printString, ' per second.' ]!
>> -                       [ ((count * 1000) / (endTime - startTime)) asFloat printString, ' per second.' ]!
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.491.mcz

Andreas.Raab
On 9/10/2010 10:41 AM, Nicolas Cellier wrote:

> The problem is for micro benchmarks where the display is more like
>
> 1.40983424386e6 per second
>
> so roundTo: 0.001 does not solve anything (the last digits are not
> meaningfull at all).
> Using three digits, I get
>
> 1.41e6 per second
>
> which is already better (less pollution).
>
> For the other suggestions, I don't know, just did the simplest modification...

1.40983424386e6 truncated asStringWithCommas
=> 1,409,834 per second

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.491.mcz

Nicolas Cellier
2010/9/10 Andreas Raab <[hidden email]>:

> On 9/10/2010 10:41 AM, Nicolas Cellier wrote:
>>
>> The problem is for micro benchmarks where the display is more like
>>
>> 1.40983424386e6 per second
>>
>> so roundTo: 0.001 does not solve anything (the last digits are not
>> meaningfull at all).
>> Using three digits, I get
>>
>> 1.41e6 per second
>>
>> which is already better (less pollution).
>>
>> For the other suggestions, I don't know, just did the simplest
>> modification...
>
> 1.40983424386e6 truncated asStringWithCommas
> => 1,409,834 per second
>
> Cheers,
>  - Andreas
>
>

Ah yes, very nice.
Still I don't much care of the 834, and would as well be happy with 1,410,000

1) suppose there is noise (the digits are not repeatable), then they
are not meaningfull, are they?
2) if ever they are repeatable, then we don't care of optimizing the
fourth digit, do we ?
    - Today I didn't loose my time, I gained a 1.0001x speed-up in a
minor contributor !

Nicolas