use Date::Format; use DateTime; use Benchmark qw(cmpthese); sub lt { my @lt = localtime; return sprintf( "%d-%02d-%02d %02d:%02d:%02d", $lt[5] + 1900, $lt[4] + 1, $lt[3], $lt[2], $lt[1], $lt[0] ); } sub df { @lt = localtime; return Date::Format::strftime( "%Y-%m-%d %T", @lt ); } sub dt1 { return DateTime->now( time_zone => "local" )->strftime("%F %T"); } my $tz = DateTime::TimeZone->new( name => 'local' ); sub dt2 { return DateTime->now( time_zone => $tz )->strftime("%F %T"); } cmpthese( 100000, { localtime => \<, 'Date::Format' => \&df, 'DateTime' => \&dt1, 'DateTime (cached tz)' => \&dt2, } );