[Israel.pm] why does upper-casing costs more than lower-casing?
Nathan Abu
aloha2004 at gmail.com
Thu Feb 23 17:51:21 PST 2012
Hi,
been wondering why does *uc* takes almost twice the time compared to *lc*?
code:
*#!/usr/bin/perl*
*use warnings;*
*use strict;*
*use Benchmark qw(cmpthese timethese :hireswallclock);*
*my $string = 'Phone: 054-8765434 Email: nabu at lknhy4564.com 054-3232
888-22222 abdsx';*
*
*
*cmpthese(*
* timethese(*
* 50_000_000,*
* { to_lower => sub { lc($string); },*
* to_upper => sub { uc($string); }*
* }*
* )*
*)*
*
*
which results in:
*Benchmark: timing 50000000 iterations of to_lower, to_upper...*
* to_lower: 8.45244 wallclock secs ( 8.45 usr + -0.00 sys = 8.45 CPU) @
5917159.76/s (n=50000000)*
* to_upper: 15.321 wallclock secs (15.31 usr + 0.00 sys = 15.31 CPU) @
3265839.32/s (n=50000000)*
* Rate to_upper to_lower*
*to_upper 3265839/s -- -45%*
*to_lower 5917160/s 81% *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20120224/bb851335/attachment.htm
More information about the Perl
mailing list