More File Performance Q.?
Ned Konz
ned at bike-nomad.com
Thu May 16 16:25:02 UTC 2002
On Thursday 16 May 2002 08:52 am, Ned Konz wrote:
> On Thursday 16 May 2002 09:20 am, goran.hultgren at bluefish.se wrote:
> > 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):
There were a couple of bugs in the prior one (I just looked at the
output file).
And you can get less memory usage and somewhat faster performance (now
72% faster) by not copying:
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: $@) ifFalse: [ file2 nextPut: Character space
]]]].
file2 nextPutAll: line; nextPut: lf] .
file3 := StandardFileStream new.
file3 open: aFileDirectory fullName, '/', aFile, '.txt' forWrite:
true.
file3 next: file2 position putAll: file2 originalContents
startingAt: 1.
file3 close.]].
- 109 tallies, 1982 msec.
**Tree**
41.3% {819ms} ReadStream>>upTo:
|29.4% {583ms} String(SequenceableCollection)>>copyFrom:to:
| |18.3% {363ms} String(Object)>>species
| |11.0% {218ms} primitives
|6.4% {127ms} primitives
|5.5% {109ms} String>>indexOf:startingAt:ifAbsent:
26.6% {527ms} WriteStream>>nextPutAll:
|13.8% {274ms} String(SequenceableCollection)>>replaceFrom:to:with:
|12.8% {254ms} primitives
13.8% {274ms} WriteStream>>nextPut:
8.3% {165ms} primitives
3.7% {73ms} String>>beginsWith2:
|2.8% {55ms} String(SequenceableCollection)>>first
3.7% {73ms} StandardFileStream>>next:putAll:startingAt:
2.8% {55ms} StandardFileStream(FileStream)>>contentsOfEntireFile
2.8% {55ms} StandardFileStream>>next:
**Leaves**
18.3% {363ms} String(Object)>>species
13.8% {274ms} WriteStream>>nextPut:
13.8% {274ms} String(SequenceableCollection)>>replaceFrom:to:with:
12.8% {254ms} WriteStream>>nextPutAll:
11.0% {218ms} String(SequenceableCollection)>>copyFrom:to:
8.3% {165ms} UndefinedObject>>DoIt
6.4% {127ms} ReadStream>>upTo:
5.5% {109ms} String>>indexOf:startingAt:ifAbsent:
3.7% {73ms} StandardFileStream>>next:putAll:startingAt:
2.8% {55ms} String(SequenceableCollection)>>first
**Memory**
old +0 bytes
young +10,170,724 bytes
used +10,170,724 bytes
free -10,170,724 bytes
**GCs**
full 0 totalling 0ms (0.0% uptime)
incr 53 totalling 191ms (10.0% uptime), avg 4.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
|