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: [email protected] 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% *
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
