Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
1- b() is faster than a() because the extra @ary. When benchmarking very fast operations, the overhead of creating variables is not negligible. Besides that, in a() you created a %hash on each iteration of the benchmark, in b() you are reusing %hash_b (forgotten the 'my'?) 2- Same as above... you are not doing the same thing. In c() a %hash is created on each iteration, in d() a global %hash_d is used. If a 'my' is added before %hash_d, then d() is faster than c() 3- Well... Storable is slower than split (from my experience, I can tell you that split is very very fast), so... why use Storable? - Is less code, faster to write because that, and you don't need to test, debug or document it yourself. - Is safer. For example, your example fails if the data contains '|'. And if you add escape sequences decoding, how much faster will still be split? - Later you can change the serialized structure without updtaing the serializer and deserializer. - Is not so slow, is no near half slow than split based code. The following sub is faster than a():
Is easier, bah :-) Anyway, you probably will end spending more time fetching the data from the DB than deserializing it. Hope this helps, José In reply to Re: Benchmark on deserializing data
by dont_you
|
|