On Tue, 25 Nov 2008, Daisuke Maki wrote:
Yes, I wrote a crude benchmark script in
DateTime-Lite/tools/benchmar/load_times.pl
If you don't load arithmetic and strftime, DT::Lite is twice as fast plain
DT.
Rate dt dt_lite_full dt_lite
dt 46.6/s -- -13% -49%
dt_lite_full 53.7/s 15% -- -41%
dt_lite 91.7/s 97% 71% --
And again, /I know/ this isn't that much of a practical problem, because the
engineer's correct answer is "if the load time is slow, load it once, and use
some sort of persistent environment". This is mainly a marketing issue to my
audience, who, for example, includes CGI developers (i.e., persistent
environment isn't an option).
BTW, dt_lite_full is almost equivalent to using DateTime.pm, but I /think/
the difference comes from the tweak I did to switch method calls to function
calls. That can probably be tweaked in DateTime.pm, if you want me to apply
it.
Isn't this just a test of load times? How could using methods vs functions
make any difference to a module's load times?
I suspect the difference may come from several things:
1. Not loading several modules, including XSLoader and Params::Validate.
2. Not loading an XS component.
3. Not loading a default locale - DateTime ends up loading the en_US
locale when DateTime.pm is loaded. Your benchmark might actually be
_understating_ that, since your benchmark doesn't force this module to be
reloaded as well.
Creating GVs for each timezone is a waste. Creating one class, then creating
instances for each timezones are much cheaper. I discussed this briefly when
I was trying to do DateTime::TimeZone::XS, but I got warnocked.
Right, I do remember that.
Yes, it makes sense that not creating all those namespaces would reduce
memory usage.
I'm a little leary of changing things now, since it'd be backwards
incompatible. I wonder if anyone actually relies on those objects having a
namespace that includes the time zone though.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/