[squeak-dev] The Trunk: Kernel-nice.492.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 10 19:11:43 UTC 2010


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

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

Name: Kernel-nice.492
Author: nice
Time: 10 September 2010, 9:11:24.786 pm
UUID: 29865715-9a8e-c448-8d96-34eee97b5a37
Ancestors: Kernel-nice.491

Second revision of bench to display:

The rules are:

- display 10,400,000 rather than 1.04e7
- display 24 rather than 24.0
- display a fractional part only if significative

In any case, only first 3 digits are displayed, the rest are rounded to zero because considered un-meaningfull.

Above 100, every digit after the decimal point is at least in fourth position, so the decimal part won't be displayed.

=============== Diff against Kernel-nice.491 ===============

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 |
+ 		| 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]].
- 	roundTo3Digits := [:num | num roundTo: (10 raisedTo: (num numberOfDigitsInBase: 10) - 3)].
  	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) , ' seconds.' ]
- 		ifTrue: [ (roundTo3Digits value: (endTime - startTime) // 1000) printString, ' seconds.' ]
  		ifFalse:
+ 			[ (roundTo3Digits value: (count * 1000) / (endTime - startTime)) , ' per second.' ]!
- 			[ ((roundTo3Digits value: (count * 1000 * 100) // (endTime - startTime)) / 100.0) printString, ' per second.' ]!




More information about the Squeak-dev mailing list