My main issue with that example is not that it's slow, but that it's misleading.
For string scalars, Perl's length returns a value that has already been calculated (and cached) elsewhere.
It's just a dumb "accessor method" for that internally stored value, which makes caching it pointless.