develooper Front page | perl.datetime | Postings from May 2012

RE: DateTime performance

Thread Previous | Thread Next
From:
Andrew O'Brien
Date:
May 3, 2012 02:15
Subject:
RE: DateTime performance
Message ID:
3452DF734EB83845A729797590D41AE23AD5F467@Oriel-LC-Mail.oriel.com.au
> From: Philipp K. Janert [mailto:janert@ieee.org]
> Sent: Wednesday, 2 May 2012 8:29 AM
> 
> Question:
> 
> When using DateTime for a large number of
> instances, it becomes a serious performance
> drag.
...
> Is this expected behavior? And are there access
> patterns that I can use to mitigate this effect?
> (I tried to supply a time_zone explicitly, but that
> does not seem to improve things significantly.)

Hi Phillip,

My #1 tip is to pre-prepare/cache the DateTime::TimeZone object and pass it in to each creation of a DateTime object (via whatever mechanism you're using to do that). I have seen a case where we were using time_zone => 'local' in a reasonably tight datetime object creation loop and saw significant speed increases just by cutting out that chunk of processing.

In hindsight that was a silly thing to do but it became an easy win :-)

I apologise if this is what you meant by supplying a time_zone explicitly in your comment above.

I can't recommend using a tool like NYTProf highly enough on a run of your tool to spot the low hanging fruit. See https://metacpan.org/module/Devel::NYTProf

Cheers,

Andrew

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About