Available immediately from:
http://kolea.ifa.hawaii.edu/~jhoblitt/pm/DateTime-Cache-0.01.tar.gz
I'm not sure if this should be DateTime::Util::Cache instead. I prefer the Util::*
namespace but I wanted to keep the name as short as possible. As soon as a namespace
is agreed upon I'll move this to SF cvs.
This module is a subclass of DT (yes Dave, I subclassed DT again) and wraps the
constructors with Memoize.
Benchmarks and the tests from DT 0.13 are included in the ./scripts dir.
-J
--
Benchmark: running cache, cache+flush, cache+normalized, cache+normalized+flush, new,
new+normalized for at least 5 CPU seconds...
cache: 5 wallclock secs ( 5.23 usr + 0.00 sys = 5.23 CPU) @ 38544.93/s
(n=201590)
cache+flush: 5 wallclock secs ( 5.25 usr + 0.00 sys = 5.25 CPU) @ 1407.43/s (n=7389)
cache+normalized: 5 wallclock secs ( 5.16 usr + 0.00 sys = 5.16 CPU) @ 19657.56/s
(n=101433)
cache+normalized+flush: 6 wallclock secs ( 5.24 usr + 0.00 sys = 5.24 CPU) @
1358.78/s (n=7120)
new: 5 wallclock secs ( 5.33 usr + 0.00 sys = 5.33 CPU) @ 1956.66/s (n=10429)
new+normalized: 5 wallclock secs ( 5.28 usr + 0.00 sys = 5.28 CPU) @ 1867.42/s
(n=9860)
Rate cache+normalized+flush cache+flush new+normalized new
cache+normalized cache
cache+normalized+flush 1359/s -- -3% -27% -31%
-93% -96%
cache+flush 1407/s 4% -- -25% -28%
-93% -96%
new+normalized 1867/s 37% 33% -- -5%
-91% -95%
new 1957/s 44% 39% 5% --
-90% -95%
cache+normalized 19658/s 1347% 1297% 953% 905%
-- -49%
cache 38545/s 2737% 2639% 1964% 1870%
96% --
Benchmark: running cache, cache+flush, from_epoch for at least 5 CPU seconds...
cache: 5 wallclock secs ( 5.20 usr + 0.00 sys = 5.20 CPU) @ 46389.81/s
(n=241227)
cache+flush: 5 wallclock secs ( 5.27 usr + 0.00 sys = 5.27 CPU) @ 7354.65/s
(n=38759)
from_epoch: 5 wallclock secs ( 5.23 usr + 0.00 sys = 5.23 CPU) @ 1750.29/s (n=9154)
Rate from_epoch cache+flush cache
from_epoch 1750/s -- -76% -96%
cache+flush 7355/s 320% -- -84%
cache 46390/s 2550% 531% --
Benchmark: running cache, cache+flush, now for at least 5 CPU seconds...
cache: 6 wallclock secs ( 5.32 usr + 0.00 sys = 5.32 CPU) @ 48951.13/s
(n=260420)
cache+flush: 5 wallclock secs ( 5.22 usr + 0.02 sys = 5.24 CPU) @ 12701.53/s
(n=66556)
now: 6 wallclock secs ( 5.33 usr + 0.00 sys = 5.33 CPU) @ 1717.45/s (n=9154)
Rate now cache+flush cache
now 1717/s -- -86% -96%
cache+flush 12702/s 640% -- -74%
cache 48951/s 2750% 285% --
Benchmark: running cache, cache+flush, today for at least 5 CPU seconds...
cache: 6 wallclock secs ( 5.34 usr + 0.00 sys = 5.34 CPU) @ 48767.79/s
(n=260420)
cache+flush: 5 wallclock secs ( 5.30 usr + 0.00 sys = 5.30 CPU) @ 5287.36/s
(n=28023)
today: 5 wallclock secs ( 5.33 usr + 0.00 sys = 5.33 CPU) @ 1223.83/s (n=6523)
Rate today cache+flush cache
today 1224/s -- -77% -97%
cache+flush 5287/s 332% -- -89%
cache 48768/s 3885% 822% --
Benchmark: running cache, cache+flush, from_object for at least 5 CPU seconds...
cache: 6 wallclock secs ( 5.24 usr + 0.00 sys = 5.24 CPU) @ 31870.23/s
(n=167000)
cache+flush: 5 wallclock secs ( 5.28 usr + 0.00 sys = 5.28 CPU) @ 3237.69/s
(n=17095)
from_object: 5 wallclock secs ( 5.28 usr + 0.00 sys = 5.28 CPU) @ 1102.65/s (n=5822)
Rate from_object cache+flush cache
from_object 1103/s -- -66% -97%
cache+flush 3238/s 194% -- -90%
cache 31870/s 2790% 884% --
Benchmark: running cache, cache+flush, last_day_of_month for at least 5 CPU seconds...
cache: 5 wallclock secs ( 5.23 usr + 0.00 sys = 5.23 CPU) @ 44552.01/s
(n=233007)
cache+flush: 6 wallclock secs ( 5.25 usr + 0.00 sys = 5.25 CPU) @ 7657.33/s
(n=40201)
last_day_of_month: 5 wallclock secs ( 5.31 usr + 0.00 sys = 5.31 CPU) @ 1856.87/s
(n=9860)
Rate last_day_of_month cache+flush cache
last_day_of_month 1857/s -- -76% -96%
cache+flush 7657/s 312% -- -83%
cache 44552/s 2299% 482% --
Benchmark: running cache, cache+flush, from_day_of_year for at least 5 CPU seconds...
cache: 6 wallclock secs ( 5.18 usr + 0.00 sys = 5.18 CPU) @ 44116.99/s
(n=228526)
cache+flush: 5 wallclock secs ( 5.26 usr + 0.00 sys = 5.26 CPU) @ 1581.75/s (n=8320)
from_day_of_year: 5 wallclock secs ( 5.27 usr + 0.00 sys = 5.27 CPU) @ 1802.47/s
(n=9499)
Rate cache+flush from_day_of_year cache
cache+flush 1582/s -- -12% -96%
from_day_of_year 1802/s 14% -- -96%
cache 44117/s 2689% 2348% --
Benchmark: running cache, cache+flush, clone for at least 5 CPU seconds...
cache: 4 wallclock secs ( 5.26 usr + 0.00 sys = 5.26 CPU) @ 36132.89/s
(n=190059)
cache+flush: 5 wallclock secs ( 5.32 usr + 0.00 sys = 5.32 CPU) @ 12512.41/s
(n=66566)
clone: 5 wallclock secs ( 5.18 usr + 0.00 sys = 5.18 CPU) @ 67267.18/s
(n=348444)
Rate cache+flush cache clone
cache+flush 12512/s -- -65% -81%
cache 36133/s 189% -- -46%
clone 67267/s 438% 86% --