|Perl Monk, Perl Meditation|
Benchmark on deserializing databy RL (Monk)
|on Apr 26, 2007 at 20:33 UTC||Need Help??|
RL has asked for the
wisdom of the Perl Monks concerning the following question:
Hi to all,
I've done some benchmark on deserializing data and don't actually understand why the deserialization of data serialized by Storable is slower than using plain pipe-seperated serialisation.
Maybe I'm missing the obvious, made a mistake or misinterpreted what I read about Storable.
I've got sets of data which I want to store in a database on disk using only core-modules coming with perl. That results in DBM files obviously. (some 10K of datasets to store).
I'm more concerned about retrieval (frequent reads on the DB) than on storing. The code below therefore only represents retrieval, not storage.
I'm trying to serialize a datastructure in order to store using $DB_HASH format. Benchmark is deserialisation of pipe-seperated values against Storable's freeze/thaw functions.
Here is the code:
And here is the output on my box:
Ok then, now my questions:
(1) I do understand why _b_ is faster than _a_ - guess it's because of @ary acting as man-in-the-middle
(2) I do not understand why _c_ is faster than _d_. Why does $hash_ref as man-in-the-middle speed things up here?
(3) Most important I don't understand why both methods using Storable are slower than the other two using plain split for deserialization. From what I read I thought Storable was
(b) intended to be used for serializing Perl data structures.
Is there any known point (rule of thumb maybe) where Storable is faster than plain join/split stringification?
Any hint appreciated.
Thx for reading.