#!/usr/local/bin/perl -w use strict; use Benchmark; my $s = '00a0c801adc6'; timethese(100000,{ particle => sub { my $str = $s; $str =~ s/([\w]{2})(?!$)/$1:/gio; }, chipmunk => sub { my $str = $s; $str = join(':', $str =~ /../g); }, petral => sub { my $str = $s; $str = join(':', split /(?=(?:..)+$)/,$str); }, robot1 => sub { my $str = $s; $str = join(':', unpack 'a2a2a2a2a2a2', $str); }, robot2 => sub { my $str = $s; $str = join(':', unpack('a2' x (length($str)/2), $str)); }, }); #### C:\WINDOWS\Desktop>perl test_mac.pl Benchmark: timing 100000 iterations of chipmunk, particle, petral, robot1, robot2... chipmunk: 3 wallclock secs ( 2.52 usr + 0.00 sys = 2.52 CPU) @ 39682.54/s (n=100000) particle: 6 wallclock secs ( 6.48 usr + 0.00 sys = 6.48 CPU) @ 15432.10/s (n=100000) petral: 5 wallclock secs ( 6.05 usr + 0.00 sys = 6.05 CPU) @ 16528.93/s (n=100000) robot1: 2 wallclock secs ( 1.27 usr + 0.00 sys = 1.27 CPU) @ 78740.16/s (n=100000) robot2: 3 wallclock secs ( 3.02 usr + 0.00 sys = 3.02 CPU) @ 33112.58/s (n=100000)