Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Benchmark on deserializing data

by adrianh (Chancellor)
on Apr 26, 2007 at 21:01 UTC ( #612269=note: print w/replies, xml ) Need Help??

in reply to Benchmark on deserializing data

Most important I don't understand why both methods using Storable are slower than the other two using plain split for deserialization.

It's because Storable can cope with pretty much anything. Try doing something like this:

use Storable qw( freeze thaw ); { no warnings 'once'; $Storable::Deparse=1; $Storable::Eval=1; } thaw( freeze( sub { print "hello world\n" } ) )->();

with split - or persisting something with with a "|" character in a hash value :-)

Storable is general - and you'll sometimes pay for that with speed.

Replies are listed 'Best First'.
Re^2: Benchmark on deserializing data
by aufflick (Deacon) on Apr 27, 2007 at 00:42 UTC
    It's worth pointing out to anyone stumbling upon this thread that the above example will only restore a self contained anonymous sub and not a closure (ie. storable doesn't attempt to restore the lexical state of the sub { }).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://612269]
[hippo]: For a self-contained application which can therefore ensure thread safety it seems like a sensible approach.
[choroba]: No, if there are no threads, then the user wants to use MCE. If there are threads, the user can choose.
[1nickt]: choroba Understood. I'm wondering about the logic in a cpanfile. If the perl doesn't support threads, it's easy: require MCE. If the perl does support threads, as you say the user has a choice, so require both? Or, assume that irrespective of the choide
[1nickt]: ... choice, the threaded-perl user *probably* wants to use threads, therefore only require threads and leave MCE out, allowing the user to manually install if desired?
[choroba]: just require any of MCE and threads. Not sure if that's possible in the cpanfile, but should be possible early in the Makefile

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2017-10-18 13:20 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (244 votes). Check out past polls.