El 23/07/2013 9:01, Norbert Hartl escribió:
Am 23.07.2013 um 13:20 schrieb Hernán Morales Durand <hernan.mora...@gmail.com>:
Have a look at InstanceEncoder
http://www.smalltalkhub.com/#!/~hernan/InstanceEncoder
Thanks, how would you say it works compared to store an Fuel ByteArray?
This is not difficult to test. First save your image and download this
file, is the chromosome 22 of a human reference genome (about 10mb of
gzip file):
| client ttr object fileName fStream |
fileName := 'hs_alt_HuRef_chr22.fa.gz'.
[ client := (FTPClient openOnHostNamed: 'ftp.ncbi.nlm.nih.gov')
loginUser: 'anonymous' password: '';
binary;
changeDirectoryTo: 'genomes/H_sapiens/CHR_22'.
(FileStream newFileNamed: fileName)
binary;
nextPutAll: (client getFileNamed: fileName);
close ]
on: NetworkError, LoginFailedException
do: [ : ex | self error: 'Connection failed' ].
Now storing with InstanceEncoder:
fileName := 'hs_alt_HuRef_chr22.fa.gz'.
ttr := [ Object store: fileName asFileReference contents asSelector:
#storedObjectInstanceEncoder ] timeToRun.
(Duration milliSeconds: ttr) asSeconds.
And with Fuel
Smalltalk garbageCollect.
fileName := 'hs_alt_HuRef_chr22.fa.gz'.
ttr := [ Object class compile: 'storedObjectFuel
^ ', (ByteArray streamContents: [ : stream | FLSerializer serialize:
fileName asFileReference contents on: stream ]) storeString ] timeToRun.
(Duration milliSeconds: ttr) asSeconds.
Results for writing
===================
InstanceEncoder avg: 8 sec.
Fuel avg: 45 sec.
And reading scripts:
[ Object storedObjectInstanceEncoder ] timeToRun.
[ FLMaterializer materializeFromByteArray: Object storedObjectFuel ]
timeToRun
Results for reading
===================
InstanceEncoder avg: 3955 msec
Fuel avg: 70 msec
And the final cleaning of course :)
Object class removeSelector: #storedObjectFuel.
Object class removeSelector: #storedObjectInstanceEncoder.
Cheers,
Hernán
Norbert
El 23/07/2013 7:47, Norbert Hartl escribió:
I try to untangle my modules. I have a parser that creates a model and a tool
that uses that model. For testing it is convenient to just generate the model
and work with it. But this way I introduce dependencies which always pulls
everything in.
In order to untangle I would need a way to easily serialize the runtime model
into methods or something similar. Anything that can be transported via
monticello is ok. I just don't want to have dependencies to present of external
files. That would just change the problem but not solving it.
Any ideas?
Norbert
.