in reply to Which one is best for optimization

Why don't you just try it? Such questions usually can't be answered in general, because the performance characteristics depend on the nature and size of your data.

So use Benchmark and Devel::Size (or similar modules) to find out what's best for you.

(Update: with cmp you compare with string semantics, are you sure you want that?)