[squeak-dev] Re: Speeding up Float Numbers reading
Andreas Raab
andreas.raab at gmx.de
Tue Mar 11 06:44:54 UTC 2008
nicolas cellier wrote:
> Remaining performance is mostly explained by method inlining, which is
> not desirable in SqNumberParser. It could however be subclassed with an
> OptimizedSqueakFloatParser (I did not...).
Indeed. You should *very* seriously consider this. I'm including the
tallies of the reader below (done with the Qwaq profiler which does
sub-millisecond primitive sampling) and look how much time you spend
elsewhere: Character>>digitValue is a bitch (going through
EncodedCharSet every time) and PositionableStream>>atEnd is called a
gigazillion times. Compare this with the streamlined version in
ReadStream>>nextFloat and you can see where the difference is in inlining.
Cheers,
- Andreas
----------------------- Float>>readFrom: --------------------------
100.0 (10,406) Compiler evaluate:in:to:notifying:ifFail:logged:
100.0 (10,406) TXmlConstructor class DoIt
100.0 (10,406) TXmlConstructor class runFloatTest:
94.7 (9,854) Float class readFrom:
|94.6 (9,844) Float class [Number class] readFrom:
| 50.3 (5,234) Float class [Number class]
readRemainderOf:from:base:withSign:
| |26.0 (2,706) Integer class readFrom:base:
| | |10.1 (1,051) Character digitValue
| | | |9.7 (1,009) EncodedCharSet class charsetAt:
| | | | 9.7 (1,009) Array [SequenceableCollection]
at:ifAbsent:
| | | | 9.1 (947) Object at:
| | |7.5 (780) ReadStream [PositionableStream] peekFor:
| | | |5.8 (604) PositionableStream atEnd
| | | |1.7 (177) ReadStream next
| | |5.1 (531) PositionableStream atEnd
| | |3.2 (333) ReadStream next
| | | 1.7 (177) ByteString at:
| |9.2 (957) SmallInteger asFloat
| |4.1 (427) Float class [Number class]
canParseExponentFor:base:from:
| | |2.9 (302) ByteString [SequenceableCollection] includes:
| | | |2.9 (302) ByteString [String] indexOf:
| | | | 2.9 (302) ByteString class
indexOfAscii:inString:startingAt:
| | |1.2 (125) ReadStream [PositionableStream] peek
| |3.9 (406) ReadStream [PositionableStream] peekFor:
| | |3.5 (364) PositionableStream atEnd
| |2.7 (281) Character digitValue
| | |2.6 (271) EncodedCharSet class charsetAt:
| | | 2.6 (271) Array [SequenceableCollection] at:ifAbsent:
| | | 2.1 (219) Object at:
| |2.2 (229) Float class [Number class]
canParseAsScaledDecimal...digits:base:sign:from:
| | |1.8 (187) ReadStream [PositionableStream] peek
| |1.1 (114) PositionableStream atEnd
| 30.3 (3,153) Integer class readFrom:base:
| |13.1 (1,363) Character digitValue
| | |12.6 (1,311) EncodedCharSet class charsetAt:
| | | 12.5 (1,301) Array [SequenceableCollection] at:ifAbsent:
| | | 11.5 (1,197) Object at:
| |7.1 (739) PositionableStream atEnd
| |5.9 (614) ReadStream [PositionableStream] peekFor:
| | |5.4 (562) PositionableStream atEnd
| |4.1 (427) ReadStream next
| | 2.0 (208) ByteString at:
| 7.6 (791) ReadStream [PositionableStream] peekFor:
| |6.3 (656) PositionableStream atEnd
| |1.2 (125) ReadStream next
| 6.5 (676) ReadStream [Stream] nextMatchAll:
| 4.5 (468) ByteString [SequenceableCollection] do:
| |4.4 (458) ArrayedCollection size
| 1.7 (177) ReadStream next
3.7 (385) ReadStream [PositionableStream] skipSeparators
|2.8 (291) PositionableStream atEnd
1.6 (166) PositionableStream atEnd
**Leaves**
42.7 (4,443) PositionableStream atEnd
23.7 (2,466) Object at:
9.6 (999) SmallInteger asFloat
6.0 (624) ByteString at:
4.8 (499) ArrayedCollection size
4.7 (489) ReadStream next
3.0 (312) ByteString class indexOfAscii:inString:startingAt:
**Memory**
old +0 bytes
young +399,516 bytes
used +399,516 bytes
free -399,516 bytes
**GCs**
full 0 totalling 0ms (0.0% uptime)
incr 170 totalling 690ms (7.0% uptime), avg 4.0ms
tenures 0
root table 0 overflows
------------------------ Readstream>>nextFloat ------------------------
100.0 (744) Compiler evaluate:in:to:notifying:ifFail:logged:
100.0 (744) TXmlConstructor class DoIt
100.0 (744) TXmlConstructor class runFloatTest:
100.0 (744) ReadStream nextFloat
74.8 (557) ByteString byteAt:
13.6 (101) ByteString class findFirstInString:inSet:startingAt:
11.5 (86) SmallInteger asFloat
**Leaves**
74.9 (557) ByteString byteAt:
13.6 (101) ByteString class findFirstInString:inSet:startingAt:
11.5 (86) SmallInteger asFloat
**Memory**
old +0 bytes
young -562,888 bytes
used -562,888 bytes
free +562,888 bytes
**GCs**
full 0 totalling 0ms (0.0% uptime)
incr 13 totalling 18ms (2.0% uptime), avg 1.0ms
tenures 0
root table 0 overflows
More information about the Squeak-dev
mailing list
|