Why? Sounds premature to me
#!/usr/bin/perl -- use strict; use warnings; use Benchmark qw( cmpthese ); # Make bytes:: functions available, but use character semantics. use bytes; no bytes; cmpthese( -3, { bytes => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while bytes::length($smileys); }, utf8 => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while length($smileys); }, substr => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while ord substr($smileys,0,1); }, notnot => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while !! $smileys; }, '!!bytes' => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while !! bytes::length($smileys); }, '!!utf8' => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while !! length $smileys; }, 'ne""' => sub { my $smileys = "\x{263a}" x 10_000; chop($smileys) while $smileys ne ""; }, } ); __END__ Rate substr utf8 !!utf8 bytes !!bytes ne"" notnot substr 3.75/s -- -3% -4% -97% -97% -99% -99% utf8 3.86/s 3% -- -1% -97% -97% -99% -99% !!utf8 3.90/s 4% 1% -- -97% -97% -99% -99% bytes 119/s 3066% 2972% 2942% -- -0% -71% -74% !!bytes 119/s 3081% 2987% 2956% 0% -- -71% -74% ne"" 406/s 10740% 10419% 10314% 242% 241% -- -10% notnot 451/s 11928% 11572% 11455% 280% 278% 11% --

In reply to Re: Alternative to bytes::length() by Anonymous Monk
in thread Alternative to bytes::length() by creamygoodness

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.