More File Performance Q.?
Ned Konz
ned at bike-nomad.com
Thu May 16 15:52:17 UTC 2002
On Thursday 16 May 2002 09:20 am, goran.hultgren at bluefish.se wrote:
> Ned Konz <ned at bike-nomad.com> wrote:
> [SNIP]
>
> > file2 nextPutAll: line; nextPut: cr] .
>
> I looked at StandardFileStream>>nextPutAll: and it seems to write
> at every call, ie, it is not buffered at all, right?
>
> So, I don't remember what the assignment was, but what happens if
> you add a write buffer into the game? The MessageTally looks like
> it could make use of such a buffer.
Very true. Though it's costly in terms of memory, it gets another 50%
performance boost. So this only takes 2207 msec (a total of 69%
improvement over the original):
MessageTally spyOn:
[
lf := Character lf.
cr := Character cr.
aFileDirectory := FileDirectory on: '/home/ned/Squeak/3.2/mailtest'.
aFileList := aFileDirectory fileNames.
aFileList do:
[ :aFile |
file1 := StandardFileStream new.
file1 open: aFileDirectory fullName, '/', aFile forWrite: false.
file1 := ReadStream on: file1 contentsOfEntireFile.
file1 reset.
file2 := WriteStream on: (String new: file1 size + 100000).
[file1 atEnd] whileFalse:
[ line := file1 upTo: lf.
line size >= 4 ifTrue: [ | firstChar |
firstChar := line at: 1.
(firstChar = $f or: [ firstChar = $F ]) ifTrue:
[ (line beginsWith2: 'from') ifTrue:
[(line includes: $@) ifTrue: [ file2 nextPut: Character space
]]]].
file2 nextPutAll: line; nextPut: cr] .
file3 := StandardFileStream new.
file3 open: aFileDirectory fullName, '/', aFile, '.txt' forWrite:
true.
file3 nextPutAll: file2 contents.
file3 close.]].
- 121 tallies, 2207 msec.
**Tree**
46.3% {1022ms} ReadStream>>upTo:
|28.9% {638ms} String(SequenceableCollection)>>copyFrom:to:
| |14.9% {329ms} primitives
| |13.2% {291ms} String(Object)>>species
|9.9% {218ms} primitives
|7.4% {163ms} String>>indexOf:startingAt:ifAbsent:
19.0% {419ms} WriteStream>>nextPutAll:
|11.6% {256ms} primitives
|7.4% {163ms} String(SequenceableCollection)>>replaceFrom:to:with:
| 6.6% {146ms} primitives
11.6% {256ms} WriteStream>>nextPut:
10.7% {236ms} primitives
5.8% {128ms} WriteStream>>contents
|5.8% {128ms} String(SequenceableCollection)>>copyFrom:to:
3.3% {73ms} StandardFileStream(FileStream)>>contentsOfEntireFile
|3.3% {73ms} StandardFileStream>>next:
| 2.5% {55ms} StandardFileStream(PositionableStream)>>nextInto:
| 2.5% {55ms} StandardFileStream>>next:into:startingAt:
2.5% {55ms} StandardFileStream>>nextPutAll:
**Leaves**
20.7% {457ms} String(SequenceableCollection)>>copyFrom:to:
13.2% {291ms} String(Object)>>species
11.6% {256ms} WriteStream>>nextPutAll:
11.6% {256ms} WriteStream>>nextPut:
10.7% {236ms} UndefinedObject>>DoIt
9.9% {218ms} ReadStream>>upTo:
7.4% {163ms} String>>indexOf:startingAt:ifAbsent:
6.6% {146ms} String(SequenceableCollection)>>replaceFrom:to:with:
2.5% {55ms} StandardFileStream>>next:into:startingAt:
2.5% {55ms} StandardFileStream>>nextPutAll:
**Memory**
old +0 bytes
young +14,834,784 bytes
used +14,834,784 bytes
free -14,834,784 bytes
**GCs**
full 0 totalling 0ms (0.0% uptime)
incr 54 totalling 316ms (14.0% uptime), avg 6.0ms
tenures 0
root table 0 overflows
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|