More File Performance Q.?
Ned Konz
ned at bike-nomad.com
Thu May 16 15:05:31 UTC 2002
OK Bob,
Using your beginsWith2: I was able to get the time on a 4+Mb file down
from 7125 to 4186 msec (a 41% improvement).
|file1 file2 aFileDirectory aFileList line lf cr|
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 := StandardFileStream new.
file2 open: aFileDirectory fullName, '/', aFile, '.txt' forWrite:
true.
[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] .
file2 close.]].
The MessageTally on this looks like:
- 209 tallies, 4186 msec.
**Tree**
45.5% {1905ms} ReadStream>>upTo:
|25.4% {1063ms} String(SequenceableCollection)>>copyFrom:to:
| |14.4% {603ms} primitives
| |11.0% {460ms} String(Object)>>species
|12.0% {502ms} primitives
|8.1% {339ms} String>>indexOf:startingAt:ifAbsent:
20.6% {862ms} StandardFileStream>>nextPutAll:
20.1% {841ms} StandardFileStream>>nextPut:
9.6% {402ms} primitives
**Leaves**
20.6% {862ms} StandardFileStream>>nextPutAll:
20.1% {841ms} StandardFileStream>>nextPut:
14.4% {603ms} String(SequenceableCollection)>>copyFrom:to:
12.0% {502ms} ReadStream>>upTo:
11.0% {460ms} String(Object)>>species
9.6% {402ms} UndefinedObject>>DoIt
8.1% {339ms} String>>indexOf:startingAt:ifAbsent:
**Memory**
old +0 bytes
young +4,959,044 bytes
used +4,959,044 bytes
free -4,959,044 bytes
**GCs**
full 0 totalling 0ms (0.0% uptime)
incr 54 totalling 202ms (5.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
|