Rate ikegami code bfdi code ikegami code 16393443/s -- -20% bfdi code 20408163/s 24% -- #### #!/usr/local/bin/perl use Benchmark qw/ timethis cmpthese /; use Date::Manip; use POSIX qw/strftime/; use Time::Local qw/ timegm_nocheck /; sub get_using_date_manip { my $today_dt = &ParseDate("today"); my $new_dt = &Date_GetNext($today_dt, 'Thu', 1); return &UnixDate($new_dt, "%Y-%m-%d"); } sub get_using_posix_and_time_local { my ($sec,$min,$hour,$day,$mon,$year,$wday) = localtime(); # Defaults to now. $year += 1900; $day += (7 - $wday + 4) % 7; $next_th = timegm_nocheck(0,0,0,$mday,$mon,$year); return strftime('%Y-%m-%d', localtime($next_th)); } cmpthese(10_000_000, { 'bfdi code' => &get_using_date_manip, 'ikegami code' => &get_using_posix_and_time_local, });