| Filename | /zpool_host_mnt/mnt/home/s1/repos/perl-DateTime-Format-Alami/lib/DateTime/Format/Alami.pm |
| Statements | Executed 63784 statements in 80.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 4246 | 10 | 2 | 67.9ms | 2.38s | DateTime::Format::Alami::CORE:match (opcode) |
| 1000 | 1 | 1 | 42.0ms | 2.64s | DateTime::Format::Alami::parse_datetime |
| 3000 | 1 | 1 | 26.2ms | 2.32s | DateTime::Format::Alami::a_dateymd |
| 3000 | 1 | 1 | 11.4ms | 901ms | DateTime::Format::Alami::a_today |
| 4 | 4 | 2 | 4.82ms | 13.7ms | DateTime::Format::Alami::new |
| 3 | 3 | 2 | 2.26ms | 2.27ms | DateTime::Format::Alami::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 1.77ms | 2.14ms | DateTime::Format::Alami::BEGIN@114 |
| 1000 | 1 | 1 | 1.44ms | 1.44ms | DateTime::Format::Alami::_reset |
| 1 | 1 | 1 | 1.25ms | 10.9ms | DateTime::Format::Alami::BEGIN@394 |
| 1 | 1 | 1 | 746µs | 780µs | DateTime::Format::Alami::BEGIN@9 |
| 1 | 1 | 1 | 54µs | 70µs | DateTime::Format::Alami::o_monthname |
| 3 | 2 | 1 | 53µs | 76µs | DateTime::Format::Alami::o_durwords |
| 1 | 1 | 1 | 40µs | 50µs | DateTime::Format::Alami::o_dow |
| 33 | 1 | 1 | 36µs | 36µs | DateTime::Format::Alami::CORE:substcont (opcode) |
| 56 | 2 | 1 | 35µs | 35µs | DateTime::Format::Alami::CORE:subst (opcode) |
| 1 | 1 | 1 | 33µs | 33µs | DateTime::Format::Alami::BEGIN@6 |
| 1 | 1 | 1 | 25µs | 25µs | DateTime::Format::Alami::CORE:sort (opcode) |
| 2 | 2 | 1 | 19µs | 26µs | DateTime::Format::Alami::o_timedurwords |
| 4 | 4 | 3 | 16µs | 16µs | DateTime::Format::Alami::CORE:qr (opcode) |
| 2 | 2 | 1 | 15µs | 73µs | DateTime::Format::Alami::o_dur |
| 1 | 1 | 1 | 12µs | 33µs | DateTime::Format::Alami::BEGIN@497 |
| 1 | 1 | 1 | 10µs | 15µs | DateTime::Format::Alami::BEGIN@7 |
| 1 | 1 | 1 | 9µs | 22µs | DateTime::Format::Alami::BEGIN@247 |
| 1 | 1 | 1 | 9µs | 116µs | DateTime::Format::Alami::BEGIN@11 |
| 1 | 1 | 1 | 9µs | 21µs | DateTime::Format::Alami::BEGIN@50 |
| 1 | 1 | 1 | 9µs | 21µs | DateTime::Format::Alami::BEGIN@160 |
| 1 | 1 | 1 | 9µs | 17µs | DateTime::Format::Alami::BEGIN@8 |
| 1 | 1 | 1 | 9µs | 24µs | DateTime::Format::Alami::o_timedur |
| 1 | 1 | 1 | 8µs | 18µs | DateTime::Format::Alami::BEGIN@504 |
| 1 | 1 | 1 | 5µs | 31µs | DateTime::Format::Alami::odur_dur |
| 1 | 1 | 1 | 2µs | 2µs | DateTime::Format::Alami::pdur_dur |
| 1 | 1 | 1 | 2µs | 2µs | DateTime::Format::Alami::o_dayint |
| 1 | 1 | 1 | 2µs | 2µs | DateTime::Format::Alami::o_hour |
| 1 | 1 | 1 | 1µs | 1µs | DateTime::Format::Alami::o_monthint |
| 1 | 1 | 1 | 1µs | 1µs | DateTime::Format::Alami::o_yearint |
| 1 | 1 | 1 | 1µs | 1µs | DateTime::Format::Alami::o_minute |
| 1 | 1 | 1 | 1µs | 1µs | DateTime::Format::Alami::o_second |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::_now_if_unset |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::_parse_dur |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::_reset_dur |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::_today_if_unset |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_date_time |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_dur_ago |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_dur_later |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_now |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_time |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_tomorrow |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_which_dow |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::a_yesterday |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::adur_dur |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::Alami::parse_datetime_duration |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package DateTime::Format::Alami; | ||||
| 2 | |||||
| 3 | # DATE | ||||
| 4 | # VERSION | ||||
| 5 | |||||
| 6 | 2 | 59µs | 1 | 33µs | # spent 33µs within DateTime::Format::Alami::BEGIN@6 which was called:
# once (33µs+0s) by Role::Tiny::_load_module at line 6 # spent 33µs making 1 call to DateTime::Format::Alami::BEGIN@6 |
| 7 | 2 | 28µs | 2 | 19µs | # spent 15µs (10+4) within DateTime::Format::Alami::BEGIN@7 which was called:
# once (10µs+4µs) by Role::Tiny::_load_module at line 7 # spent 15µs making 1 call to DateTime::Format::Alami::BEGIN@7
# spent 4µs making 1 call to strict::import |
| 8 | 2 | 29µs | 2 | 26µs | # spent 17µs (9+9) within DateTime::Format::Alami::BEGIN@8 which was called:
# once (9µs+9µs) by Role::Tiny::_load_module at line 8 # spent 17µs making 1 call to DateTime::Format::Alami::BEGIN@8
# spent 9µs making 1 call to warnings::import |
| 9 | 2 | 768µs | 2 | 815µs | # spent 780µs (746+34) within DateTime::Format::Alami::BEGIN@9 which was called:
# once (746µs+34µs) by Role::Tiny::_load_module at line 9 # spent 780µs making 1 call to DateTime::Format::Alami::BEGIN@9
# spent 34µs making 1 call to Log::Any::IfLOG::import |
| 10 | |||||
| 11 | 2 | 208µs | 2 | 223µs | # spent 116µs (9+107) within DateTime::Format::Alami::BEGIN@11 which was called:
# once (9µs+107µs) by Role::Tiny::_load_module at line 11 # spent 116µs making 1 call to DateTime::Format::Alami::BEGIN@11
# spent 107µs making 1 call to Role::Tiny::import |
| 12 | |||||
| 13 | 1 | 3µs | my @short_mons = qw(jan feb mar apr may jun jul aug sep oct nov dec); | ||
| 14 | 1 | 1µs | my @dow = qw(monday tuesday wednesday thursday friday saturday sunday); | ||
| 15 | |||||
| 16 | 1 | 3µs | 1 | 6µs | requires 'o_num'; # spent 6µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 17 | 1 | 900ns | 1 | 2µs | requires '_parse_num'; # spent 2µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 18 | |||||
| 19 | 1 | 900ns | 1 | 1µs | requires 'w_year'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 20 | 1 | 800ns | 1 | 1µs | requires 'w_month'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 21 | 1 | 800ns | 1 | 1µs | requires 'w_week'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 22 | 1 | 900ns | 1 | 1µs | requires 'w_day'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 23 | 1 | 800ns | 1 | 1µs | requires 'w_hour'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 24 | 1 | 800ns | 1 | 1µs | requires 'w_minute'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 25 | 1 | 800ns | 1 | 1µs | requires 'w_second'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 26 | |||||
| 27 | 1 | 17µs | 12 | 16µs | requires "w_$_" for @short_mons; # spent 16µs making 12 calls to Role::Tiny::__ANON__[Role/Tiny.pm:86], avg 1µs/call |
| 28 | 1 | 10µs | 7 | 8µs | requires "w_$_" for @dow; # spent 8µs making 7 calls to Role::Tiny::__ANON__[Role/Tiny.pm:86], avg 1µs/call |
| 29 | |||||
| 30 | 1 | 800ns | 1 | 1µs | requires 'p_now'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 31 | 1 | 800ns | 1 | 1µs | requires 'p_today'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 32 | 1 | 700ns | 1 | 1µs | requires 'p_yesterday'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 33 | 1 | 800ns | 1 | 1µs | requires 'p_tomorrow'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 34 | 1 | 800ns | 1 | 1µs | requires 'p_dateymd'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 35 | 1 | 800ns | 1 | 2µs | requires 'o_date'; # spent 2µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 36 | 1 | 800ns | 1 | 1µs | requires 'p_dur_ago'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 37 | 1 | 800ns | 1 | 1µs | requires 'p_dur_later'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 38 | 1 | 700ns | 1 | 1µs | requires 'p_which_dow'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 39 | 1 | 700ns | 1 | 1µs | requires 'p_time'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 40 | 1 | 700ns | 1 | 1µs | requires 'p_date_time'; # spent 1µs making 1 call to Role::Tiny::__ANON__[Role/Tiny.pm:86] |
| 41 | |||||
| 42 | our ($m, $o); | ||||
| 43 | # spent 13.7ms (4.82+8.86) within DateTime::Format::Alami::new which was called 4 times, avg 3.42ms/call:
# once (4.80ms+8.86ms) by main::BEGIN@0 at line 94 of lib/DateTime/Format/Alami/EN.pm
# once (8µs+0s) by main::BEGIN@0 at line 95 of lib/DateTime/Format/Alami/EN.pm
# once (8µs+0s) by main::RUNTIME at line 1 of -e
# once (4µs+0s) by main::BEGIN@0 at line 96 of lib/DateTime/Format/Alami/EN.pm | ||||
| 44 | 4 | 2µs | my $class = shift; | ||
| 45 | 4 | 2µs | if ($class eq __PACKAGE__) { | ||
| 46 | die "Use one of the DateTime::Format::Alami::* instead, ". | ||||
| 47 | "e.g. DateTime::Format::Alami::EN"; | ||||
| 48 | } | ||||
| 49 | 4 | 4µs | my $self = bless {}, $class; | ||
| 50 | 2 | 577µs | 2 | 33µs | # spent 21µs (9+12) within DateTime::Format::Alami::BEGIN@50 which was called:
# once (9µs+12µs) by Role::Tiny::_load_module at line 50 # spent 21µs making 1 call to DateTime::Format::Alami::BEGIN@50
# spent 12µs making 1 call to strict::unimport |
| 51 | 4 | 10µs | unless (${"$class\::RE_DT"} && ${"$class\::RE_DUR"}) { | ||
| 52 | 1 | 590µs | require Class::Inspector; | ||
| 53 | 1 | 565µs | require Data::Graph::Util; | ||
| 54 | |||||
| 55 | 1 | 5µs | 1 | 476µs | my $meths = Class::Inspector->methods($class); # spent 476µs making 1 call to Class::Inspector::methods |
| 56 | 1 | 400ns | my %pats; # key = "p_..." | ||
| 57 | my %pat_lengths; # key = "p_..." | ||||
| 58 | my %graph; | ||||
| 59 | 1 | 7µs | for my $meth (@$meths) { | ||
| 60 | 78 | 155µs | 78 | 48µs | next unless $meth =~ /^(odur|o|pdur|p)_/; # spent 48µs making 78 calls to DateTime::Format::Alami::CORE:match, avg 617ns/call |
| 61 | 28 | 55µs | 28 | 283µs | my $pat = $self->$meth; # spent 70µs making 1 call to DateTime::Format::Alami::o_monthname
# spent 50µs making 1 call to DateTime::Format::Alami::o_dow
# spent 47µs making 1 call to DateTime::Format::Alami::o_dur
# spent 31µs making 1 call to DateTime::Format::Alami::odur_dur
# spent 24µs making 1 call to DateTime::Format::Alami::o_timedur
# spent 21µs making 1 call to DateTime::Format::Alami::o_durwords
# spent 11µs making 1 call to DateTime::Format::Alami::o_timedurwords
# spent 2µs making 1 call to DateTime::Format::Alami::EN::p_dateymd
# spent 2µs making 1 call to DateTime::Format::Alami::pdur_dur
# spent 2µs making 1 call to DateTime::Format::Alami::EN::o_ampm
# spent 2µs making 1 call to DateTime::Format::Alami::EN::p_which_dow
# spent 2µs making 1 call to DateTime::Format::Alami::o_dayint
# spent 2µs making 1 call to DateTime::Format::Alami::o_hour
# spent 2µs making 1 call to DateTime::Format::Alami::EN::p_date_time
# spent 2µs making 1 call to DateTime::Format::Alami::EN::p_dur_ago
# spent 1µs making 1 call to DateTime::Format::Alami::EN::o_cardinal_suffix
# spent 1µs making 1 call to DateTime::Format::Alami::EN::p_dur_later
# spent 1µs making 1 call to DateTime::Format::Alami::EN::p_now
# spent 1µs making 1 call to DateTime::Format::Alami::EN::p_today
# spent 1µs making 1 call to DateTime::Format::Alami::EN::p_yesterday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::o_date
# spent 1µs making 1 call to DateTime::Format::Alami::EN::p_time
# spent 1µs making 1 call to DateTime::Format::Alami::o_monthint
# spent 1µs making 1 call to DateTime::Format::Alami::o_yearint
# spent 1µs making 1 call to DateTime::Format::Alami::EN::p_tomorrow
# spent 1µs making 1 call to DateTime::Format::Alami::o_minute
# spent 1µs making 1 call to DateTime::Format::Alami::EN::o_num
# spent 1µs making 1 call to DateTime::Format::Alami::o_second |
| 62 | 28 | 55µs | 28 | 12µs | my $is_p = $meth =~ /^p_/; # spent 12µs making 28 calls to DateTime::Format::Alami::CORE:match, avg 429ns/call |
| 63 | 28 | 40µs | 28 | 5µs | my $is_pdur = $meth =~ /^pdur_/; # spent 5µs making 28 calls to DateTime::Format::Alami::CORE:match, avg 189ns/call |
| 64 | 78 | 196µs | 61 | 56µs | $pat =~ s/<(\w+)>/push @{$graph{$meth}}, $1; "(?\&$1)"/eg; # spent 36µs making 33 calls to DateTime::Format::Alami::CORE:substcont, avg 1µs/call
# spent 20µs making 28 calls to DateTime::Format::Alami::CORE:subst, avg 721ns/call |
| 65 | 28 | 6µs | my $action_meth = $meth; | ||
| 66 | 56 | 64µs | 28 | 14µs | if ($is_pdur) { $action_meth =~ s/^pdur_/adur_/ } else { $action_meth =~ s/^p_/a_/ } # spent 14µs making 28 calls to DateTime::Format::Alami::CORE:subst, avg 518ns/call |
| 67 | #my $before_meth = $meth; $before_meth =~ s/^p_/before_p_/; | ||||
| 68 | #$before_meth = undef unless $is_p && $self->can($before_meth); | ||||
| 69 | $pat = join( | ||||
| 70 | "", | ||||
| 71 | "(", | ||||
| 72 | #($before_meth ? "(?{ ".($ENV{DEBUG} ? "say \"invoking $before_meth()\";" : "")."\$DateTime::Format::Alami::o->$before_meth(\$DateTime::Format::Alami::m) })" : ""), | ||||
| 73 | ($is_p || $is_pdur ? "\\b $pat \\b" : $pat), ")", | ||||
| 74 | |||||
| 75 | # we capture ourselves instead of relying on named capture | ||||
| 76 | # because subpattern capture are discarded | ||||
| 77 | "(?{ \$DateTime::Format::Alami::m->{$meth} = \$^N })", | ||||
| 78 | |||||
| 79 | 28 | 60µs | ($is_p || $is_pdur ? "(?{ ".($ENV{DEBUG} ? "say \"invoking $action_meth(\$^N)\";" : "")."\$DateTime::Format::Alami::o->{_pat} = \"$meth\"; \$DateTime::Format::Alami::o->$action_meth(\$DateTime::Format::Alami::m) })" : ""), | ||
| 80 | ); | ||||
| 81 | 28 | 14µs | $pats{$meth} = $pat; | ||
| 82 | 28 | 25µs | $pat_lengths{$meth} = length($pat); | ||
| 83 | } | ||||
| 84 | 1 | 5µs | 1 | 87µs | my @pat_names_by_deps = Data::Graph::Util::toposort(\%graph); # spent 87µs making 1 call to Data::Graph::Util::toposort |
| 85 | 1 | 14µs | my %pat_name_dep_orders = map { $pat_names_by_deps[$_] => $_ } | ||
| 86 | 0..$#pat_names_by_deps; | ||||
| 87 | 1 | 37µs | 1 | 25µs | my @pat_names = sort {( # spent 25µs making 1 call to DateTime::Format::Alami::CORE:sort |
| 88 | ($pat_name_dep_orders{$a} // 9999) <=> | ||||
| 89 | ($pat_name_dep_orders{$b} // 9999) | ||||
| 90 | || | ||||
| 91 | $pat_lengths{$b} <=> $pat_lengths{$a}) } keys %pats; | ||||
| 92 | 1 | 1µs | my $nl = $ENV{DEBUG} ? "\n" : ""; | ||
| 93 | my $re_dt = join( | ||||
| 94 | "", | ||||
| 95 | "(?&top)", $nl, | ||||
| 96 | #"(?&p_dateymd)", $nl, # testing | ||||
| 97 | "(?(DEFINE)", $nl, | ||||
| 98 | "(?<top>", join("|", | ||||
| 99 | 28 | 49µs | 28 | 8µs | map {"(?&$_)"} grep {/^p_/} @pat_names), ")$nl", # spent 8µs making 28 calls to DateTime::Format::Alami::CORE:match, avg 268ns/call |
| 100 | 29 | 99µs | 28 | 13µs | (map { "(?<$_> $pats{$_})$nl" } grep {/^(o|p)_/} @pat_names), # spent 13µs making 28 calls to DateTime::Format::Alami::CORE:match, avg 468ns/call |
| 101 | ")", # end of define | ||||
| 102 | ); | ||||
| 103 | my $re_dur = join( | ||||
| 104 | "", | ||||
| 105 | "(?&top)", $nl, | ||||
| 106 | #"(?&pdur_dur)", $nl, # testing | ||||
| 107 | "(?(DEFINE)", $nl, | ||||
| 108 | "(?<top>", join("|", | ||||
| 109 | 28 | 45µs | 28 | 4µs | map {"(?&$_)"} grep {/^pdur_/} @pat_names), ")$nl", # spent 4µs making 28 calls to DateTime::Format::Alami::CORE:match, avg 154ns/call |
| 110 | 29 | 62µs | 28 | 5µs | (map { "(?<$_> $pats{$_})$nl" } grep {/^(odur|pdur)_/} @pat_names), # spent 5µs making 28 calls to DateTime::Format::Alami::CORE:match, avg 171ns/call |
| 111 | ")", # end of define | ||||
| 112 | ); | ||||
| 113 | { | ||||
| 114 | 3 | 604µs | 2 | 2.16ms | # spent 2.14ms (1.77+367µs) within DateTime::Format::Alami::BEGIN@114 which was called:
# once (1.77ms+367µs) by Role::Tiny::_load_module at line 114 # spent 2.14ms making 1 call to DateTime::Format::Alami::BEGIN@114
# spent 20µs making 1 call to re::import |
| 115 | 1 | 1.56ms | 2 | 1.55ms | ${"$class\::RE_DT"} = qr/$re_dt/ix; # spent 1.55ms making 1 call to DateTime::Format::Alami::CORE:regcomp
# spent 1µs making 1 call to DateTime::Format::Alami::CORE:qr # spent 63.9ms executing statements in string eval |
| 116 | 1 | 248µs | 2 | 247µs | ${"$class\::RE_DUR"} = qr/$re_dur/ix; # spent 246µs making 1 call to DateTime::Format::Alami::CORE:regcomp
# spent 1µs making 1 call to DateTime::Format::Alami::CORE:qr # spent 9µs executing statements in string eval |
| 117 | } | ||||
| 118 | } | ||||
| 119 | 4 | 4µs | unless (${"$class\::MAPS"}) { | ||
| 120 | 1 | 900ns | my $maps = {}; | ||
| 121 | # month names -> num | ||||
| 122 | { | ||||
| 123 | 1 | 400ns | my $i = 0; | ||
| 124 | 1 | 1µs | for my $m (@short_mons) { | ||
| 125 | 12 | 1µs | ++$i; | ||
| 126 | 12 | 4µs | my $meth = "w_$m"; | ||
| 127 | 12 | 22µs | 12 | 12µs | for (@{ $self->$meth }) { # spent 2µs making 1 call to DateTime::Format::Alami::EN::w_jan
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_feb
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_apr
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_dec
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_oct
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_aug
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_jul
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_jun
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_mar
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_nov
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_sep
# spent 800ns making 1 call to DateTime::Format::Alami::EN::w_may |
| 128 | 24 | 18µs | $maps->{months}{$_} = $i; | ||
| 129 | } | ||||
| 130 | } | ||||
| 131 | } | ||||
| 132 | # day-of-week names -> num (monday=1, sunday=7) | ||||
| 133 | { | ||||
| 134 | 3 | 1µs | my $i = 0; | ||
| 135 | 1 | 900ns | for my $m (@dow) { | ||
| 136 | 7 | 1µs | ++$i; | ||
| 137 | 7 | 3µs | my $meth = "w_$m"; | ||
| 138 | 7 | 13µs | 7 | 7µs | for (@{ $self->$meth }) { # spent 1µs making 1 call to DateTime::Format::Alami::EN::w_friday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_saturday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_thursday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_tuesday
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_monday
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_sunday
# spent 900ns making 1 call to DateTime::Format::Alami::EN::w_wednesday |
| 139 | 14 | 10µs | $maps->{dow}{$_} = $i; | ||
| 140 | } | ||||
| 141 | } | ||||
| 142 | } | ||||
| 143 | 1 | 8µs | ${"$class\::MAPS"} = $maps; | ||
| 144 | } | ||||
| 145 | |||||
| 146 | # _time_zone is old name (<= 0.11) will be removed later | ||||
| 147 | 4 | 6µs | $self->{time_zone} //= $self->{_time_zone}; | ||
| 148 | |||||
| 149 | 4 | 18µs | $self; | ||
| 150 | } | ||||
| 151 | |||||
| 152 | # spent 1.44ms within DateTime::Format::Alami::_reset which was called 1000 times, avg 1µs/call:
# 1000 times (1.44ms+0s) by DateTime::Format::Alami::parse_datetime at line 187, avg 1µs/call | ||||
| 153 | 1000 | 176µs | my $self = shift; | ||
| 154 | 1000 | 397µs | undef $self->{_pat}; | ||
| 155 | 1000 | 163µs | undef $self->{_dt}; | ||
| 156 | 1000 | 1.63ms | undef $self->{_uses_time}; | ||
| 157 | } | ||||
| 158 | |||||
| 159 | # spent 2.64s (42.0ms+2.60) within DateTime::Format::Alami::parse_datetime which was called 1000 times, avg 2.64ms/call:
# 1000 times (42.0ms+2.60s) by main::RUNTIME at line 1 of -e, avg 2.64ms/call | ||||
| 160 | 2 | 603µs | 2 | 32µs | # spent 21µs (9+12) within DateTime::Format::Alami::BEGIN@160 which was called:
# once (9µs+12µs) by Role::Tiny::_load_module at line 160 # spent 21µs making 1 call to DateTime::Format::Alami::BEGIN@160
# spent 12µs making 1 call to strict::unimport |
| 161 | |||||
| 162 | # we require DateTime here, for all the a_* methods | ||||
| 163 | 1000 | 822µs | require DateTime; | ||
| 164 | |||||
| 165 | 1000 | 453µs | my ($self, $str, $opts) = @_; | ||
| 166 | |||||
| 167 | # allow calling as static method | ||||
| 168 | 1000 | 285µs | unless (ref $self) { $self = $self->new } | ||
| 169 | |||||
| 170 | 1000 | 379µs | $opts //= {}; | ||
| 171 | 1000 | 533µs | $opts->{format} //= 'DateTime'; | ||
| 172 | #$opts->{prefers} //= 'nearest'; | ||||
| 173 | 1000 | 224µs | $opts->{returns} //= 'first'; | ||
| 174 | |||||
| 175 | 1000 | 177µs | local $self->{time_zone} = $opts->{time_zone} if $opts->{time_zone}; | ||
| 176 | |||||
| 177 | # we need /o to avoid repeated regcomp, but we need to make it work with all | ||||
| 178 | # subclasses, so we use eval() here. | ||||
| 179 | 1000 | 1.53ms | unless (defined *{ref($self).'::_code_match_dt'}) { | ||
| 180 | 1 | 53µs | *{ref($self).'::_code_match_dt'} = eval "sub { \$_[0] =~ /(\$".ref($self)."::RE_DT)/go; \$1 }"; # spent 7.22ms executing statements in string eval # includes 8.78ms spent executing 1000 calls to 1 sub defined therein. | ||
| 181 | 1 | 500ns | die if $@; | ||
| 182 | } | ||||
| 183 | |||||
| 184 | 1000 | 178µs | $o = $self; | ||
| 185 | 1000 | 113µs | my @res; | ||
| 186 | 1000 | 126µs | while (1) { | ||
| 187 | 1000 | 831µs | 1000 | 1.44ms | $o->_reset; # spent 1.44ms making 1000 calls to DateTime::Format::Alami::_reset, avg 1µs/call |
| 188 | 1000 | 949µs | $m = {}; | ||
| 189 | 1000 | 2.50ms | 1000 | 2.39s | my $match = &{ref($self).'::_code_match_dt'}($str) or last; # spent 2.39s making 1000 calls to DateTime::Format::Alami::__ANON__[(eval 12)[lib/DateTime/Format/Alami.pm:180]:1], avg 2.39ms/call |
| 190 | 1000 | 1.43ms | 1000 | 154ms | $o->{_dt}->truncate(to=>'day') unless $o->{_uses_time}; # spent 154ms making 1000 calls to DateTime::truncate, avg 154µs/call |
| 191 | my $res = { | ||||
| 192 | verbatim => $match, | ||||
| 193 | pattern => $o->{_pat}, | ||||
| 194 | 1000 | 3.54ms | pos => pos($str) - length($match), | ||
| 195 | m => {%$m}, | ||||
| 196 | }; | ||||
| 197 | 1000 | 475µs | $res->{uses_time} = $o->{_uses_time} ? 1:0; | ||
| 198 | 1000 | 344µs | $res->{DateTime} = $o->{_dt}; | ||
| 199 | $res->{epoch} = $o->{_dt}->epoch if | ||||
| 200 | 1000 | 567µs | $opts->{format} eq 'combined' || $opts->{format} eq 'epoch'; | ||
| 201 | 1000 | 394µs | push @res, $res; | ||
| 202 | 1000 | 731µs | last if $opts->{returns} eq 'first'; | ||
| 203 | } | ||||
| 204 | |||||
| 205 | 1000 | 235µs | die "Can't parse date '$str'" unless @res; | ||
| 206 | |||||
| 207 | 1000 | 180µs | @res = ($res[-1]) if $opts->{returns} eq 'last'; | ||
| 208 | |||||
| 209 | 1000 | 4.47ms | 1000 | 237µs | if ($opts->{returns} =~ /\A(?:all_cron|earliest|latest)\z/) { # spent 237µs making 1000 calls to DateTime::Format::Alami::CORE:match, avg 237ns/call |
| 210 | # sort chronologically, note that by this time the DateTime module | ||||
| 211 | # should already have been loaded | ||||
| 212 | @res = sort { | ||||
| 213 | DateTime->compare($a->{DateTime}, $b->{DateTime}) | ||||
| 214 | } @res; | ||||
| 215 | } | ||||
| 216 | |||||
| 217 | 1000 | 2.63ms | if ($opts->{format} eq 'DateTime') { | ||
| 218 | @res = map { $_->{DateTime} } @res; | ||||
| 219 | } elsif ($opts->{format} eq 'epoch') { | ||||
| 220 | @res = map { $_->{epoch} } @res; | ||||
| 221 | } elsif ($opts->{format} eq 'verbatim') { | ||||
| 222 | @res = map { $_->{verbatim} } @res; | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | 1000 | 6.17ms | 2000 | 1.35ms | if ($opts->{returns} =~ /\A(?:all|all_cron)\z/) { # spent 1.35ms making 2000 calls to DateTime::Format::Alami::CORE:match, avg 675ns/call |
| 226 | return \@res; | ||||
| 227 | } elsif ($opts->{returns} =~ /\A(?:first|earliest)\z/) { | ||||
| 228 | return $res[0]; | ||||
| 229 | } elsif ($opts->{returns} =~ /\A(?:last|latest)\z/) { | ||||
| 230 | return $res[-1]; | ||||
| 231 | } else { | ||||
| 232 | die "Unknown returns option '$opts->{returns}'"; | ||||
| 233 | } | ||||
| 234 | } | ||||
| 235 | |||||
| 236 | sub _reset_dur { | ||||
| 237 | my $self = shift; | ||||
| 238 | undef $self->{_pat}; | ||||
| 239 | undef $self->{_dtdur}; | ||||
| 240 | } | ||||
| 241 | |||||
| 242 | sub parse_datetime_duration { | ||||
| 243 | # we require DateTime here, for all the adur_* methods | ||||
| 244 | require DateTime; | ||||
| 245 | require DateTime::Duration; | ||||
| 246 | |||||
| 247 | 2 | 966µs | 2 | 34µs | # spent 22µs (9+12) within DateTime::Format::Alami::BEGIN@247 which was called:
# once (9µs+12µs) by Role::Tiny::_load_module at line 247 # spent 22µs making 1 call to DateTime::Format::Alami::BEGIN@247
# spent 12µs making 1 call to strict::unimport |
| 248 | |||||
| 249 | my ($self, $str, $opts) = @_; | ||||
| 250 | |||||
| 251 | # allow calling as static method | ||||
| 252 | unless (ref $self) { $self = $self->new } | ||||
| 253 | |||||
| 254 | $opts //= {}; | ||||
| 255 | $opts->{format} //= 'Duration'; | ||||
| 256 | $opts->{returns} //= 'first'; | ||||
| 257 | |||||
| 258 | # we need /o to avoid repeated regcomp, but we need to make it work with all | ||||
| 259 | # subclasses, so we use eval() here. | ||||
| 260 | unless (defined *{ref($self).'::_code_match_dur'}) { | ||||
| 261 | *{ref($self).'::_code_match_dur'} = eval "sub { \$_[0] =~ /(\$".ref($self)."::RE_DUR)/go; \$1 }"; | ||||
| 262 | die if $@; | ||||
| 263 | } | ||||
| 264 | |||||
| 265 | $o = $self; | ||||
| 266 | my @res; | ||||
| 267 | while (1) { | ||||
| 268 | $o->_reset_dur; | ||||
| 269 | $m = {}; | ||||
| 270 | my $match = &{ref($self).'::_code_match_dur'}($str) or last; | ||||
| 271 | my $res = { | ||||
| 272 | verbatim => $match, | ||||
| 273 | pattern => $o->{_pat}, | ||||
| 274 | pos => pos($str) - length($match), | ||||
| 275 | m => {%$m}, | ||||
| 276 | }; | ||||
| 277 | $res->{Duration} = $o->{_dtdur}; | ||||
| 278 | if ($opts->{format} eq 'combined' || $opts->{format} eq 'seconds') { | ||||
| 279 | my $d = $o->{_dtdur}; | ||||
| 280 | $res->{seconds} = | ||||
| 281 | $d->years * 365.25*86400 + | ||||
| 282 | $d->months * 30.4375*86400 + | ||||
| 283 | $d->weeks * 7*86400 + | ||||
| 284 | $d->days * 86400 + | ||||
| 285 | $d->hours * 3600 + | ||||
| 286 | $d->minutes * 60 + | ||||
| 287 | $d->seconds + | ||||
| 288 | $d->nanoseconds * 1e-9; | ||||
| 289 | } | ||||
| 290 | push @res, $res; | ||||
| 291 | last if $opts->{returns} eq 'first'; | ||||
| 292 | } | ||||
| 293 | |||||
| 294 | die "Can't parse duration" unless @res; | ||||
| 295 | |||||
| 296 | @res = ($res[-1]) if $opts->{returns} eq 'last'; | ||||
| 297 | |||||
| 298 | # XXX support returns largest, smallest, all_sorted | ||||
| 299 | if ($opts->{returns} =~ /\A(?:all_sorted|largest|smallest)\z/) { | ||||
| 300 | my $base_dt = DateTime->now; | ||||
| 301 | # sort from smallest to largest | ||||
| 302 | @res = sort { | ||||
| 303 | DateTime::Duration->compare($a->{Duration}, $b->{Duration}, $base_dt) | ||||
| 304 | } @res; | ||||
| 305 | } | ||||
| 306 | |||||
| 307 | if ($opts->{format} eq 'Duration') { | ||||
| 308 | @res = map { $_->{Duration} } @res; | ||||
| 309 | } elsif ($opts->{format} eq 'seconds') { | ||||
| 310 | @res = map { $_->{seconds} } @res; | ||||
| 311 | } elsif ($opts->{format} eq 'verbatim') { | ||||
| 312 | @res = map { $_->{verbatim} } @res; | ||||
| 313 | } | ||||
| 314 | |||||
| 315 | if ($opts->{returns} =~ /\A(?:all|all_sorted)\z/) { | ||||
| 316 | return \@res; | ||||
| 317 | } elsif ($opts->{returns} =~ /\A(?:first|smallest)\z/) { | ||||
| 318 | return $res[0]; | ||||
| 319 | } elsif ($opts->{returns} =~ /\A(?:last|largest)\z/) { | ||||
| 320 | return $res[-1]; | ||||
| 321 | } else { | ||||
| 322 | die "Unknown returns option '$opts->{returns}'"; | ||||
| 323 | } | ||||
| 324 | } | ||||
| 325 | |||||
| 326 | 1 | 3µs | # spent 2µs within DateTime::Format::Alami::o_dayint which was called:
# once (2µs+0s) by DateTime::Format::Alami::new at line 61 | ||
| 327 | |||||
| 328 | 1 | 3µs | # spent 1µs within DateTime::Format::Alami::o_monthint which was called:
# once (1µs+0s) by DateTime::Format::Alami::new at line 61 | ||
| 329 | |||||
| 330 | 1 | 3µs | # spent 1µs within DateTime::Format::Alami::o_yearint which was called:
# once (1µs+0s) by DateTime::Format::Alami::new at line 61 | ||
| 331 | |||||
| 332 | 1 | 3µs | # spent 2µs within DateTime::Format::Alami::o_hour which was called:
# once (2µs+0s) by DateTime::Format::Alami::new at line 61 | ||
| 333 | |||||
| 334 | 1 | 3µs | # spent 1µs within DateTime::Format::Alami::o_minute which was called:
# once (1µs+0s) by DateTime::Format::Alami::new at line 61 | ||
| 335 | |||||
| 336 | 1 | 3µs | # spent 1µs within DateTime::Format::Alami::o_second which was called:
# once (1µs+0s) by DateTime::Format::Alami::new at line 61 | ||
| 337 | |||||
| 338 | # spent 70µs (54+16) within DateTime::Format::Alami::o_monthname which was called:
# once (54µs+16µs) by DateTime::Format::Alami::new at line 61 | ||||
| 339 | 1 | 500ns | my $self = shift; | ||
| 340 | "(?:" . join( | ||||
| 341 | "|", | ||||
| 342 | 25 | 34µs | 12 | 16µs | (map {my $meth="w_$_"; @{ $self->$meth }} @short_mons) # spent 2µs making 1 call to DateTime::Format::Alami::EN::w_jan
# spent 2µs making 1 call to DateTime::Format::Alami::EN::w_aug
# spent 2µs making 1 call to DateTime::Format::Alami::EN::w_mar
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_feb
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_jun
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_dec
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_apr
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_may
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_oct
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_sep
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_jul
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_nov |
| 343 | ) . ")"; | ||||
| 344 | } | ||||
| 345 | |||||
| 346 | # spent 50µs (40+10) within DateTime::Format::Alami::o_dow which was called:
# once (40µs+10µs) by DateTime::Format::Alami::new at line 61 | ||||
| 347 | 1 | 500ns | my $self = shift; | ||
| 348 | "(?:" . join( | ||||
| 349 | "|", | ||||
| 350 | 15 | 26µs | 7 | 10µs | (map {my $meth="w_$_"; @{ $self->$meth }} @dow) # spent 2µs making 1 call to DateTime::Format::Alami::EN::w_monday
# spent 2µs making 1 call to DateTime::Format::Alami::EN::w_tuesday
# spent 2µs making 1 call to DateTime::Format::Alami::EN::w_thursday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_wednesday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_friday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_saturday
# spent 1µs making 1 call to DateTime::Format::Alami::EN::w_sunday |
| 351 | ) . ")"; | ||||
| 352 | } | ||||
| 353 | |||||
| 354 | sub o_durwords { | ||||
| 355 | 3 | 700ns | my $self = shift; | ||
| 356 | "(?:" . join( | ||||
| 357 | "|", | ||||
| 358 | @{ $self->w_year }, @{ $self->w_month }, @{ $self->w_week }, | ||||
| 359 | @{ $self->w_day }, | ||||
| 360 | 3 | 32µs | 21 | 23µs | @{ $self->w_hour }, @{ $self->w_minute }, @{ $self->w_second }, # spent 4µs making 3 calls to DateTime::Format::Alami::EN::w_month, avg 1µs/call
# spent 4µs making 3 calls to DateTime::Format::Alami::EN::w_week, avg 1µs/call
# spent 4µs making 3 calls to DateTime::Format::Alami::EN::w_year, avg 1µs/call
# spent 3µs making 3 calls to DateTime::Format::Alami::EN::w_second, avg 1µs/call
# spent 3µs making 3 calls to DateTime::Format::Alami::EN::w_minute, avg 1µs/call
# spent 3µs making 3 calls to DateTime::Format::Alami::EN::w_hour, avg 1µs/call
# spent 3µs making 3 calls to DateTime::Format::Alami::EN::w_day, avg 967ns/call |
| 361 | ) . ")"; | ||||
| 362 | } | ||||
| 363 | |||||
| 364 | sub o_dur { | ||||
| 365 | 2 | 500ns | my $self = shift; | ||
| 366 | 2 | 13µs | 4 | 58µs | "(?:(" . $self->o_num . "\\s*" . $self->o_durwords . "\\s*(?:,\\s*)?)+)"; # spent 56µs making 2 calls to DateTime::Format::Alami::o_durwords, avg 28µs/call
# spent 2µs making 2 calls to DateTime::Format::Alami::EN::o_num, avg 1µs/call |
| 367 | } | ||||
| 368 | |||||
| 369 | # spent 31µs (5+26) within DateTime::Format::Alami::odur_dur which was called:
# once (5µs+26µs) by DateTime::Format::Alami::new at line 61 | ||||
| 370 | 1 | 500ns | my $self = shift; | ||
| 371 | 1 | 3µs | 1 | 26µs | $self->o_dur; # spent 26µs making 1 call to DateTime::Format::Alami::o_dur |
| 372 | } | ||||
| 373 | |||||
| 374 | # spent 2µs within DateTime::Format::Alami::pdur_dur which was called:
# once (2µs+0s) by DateTime::Format::Alami::new at line 61 | ||||
| 375 | 1 | 500ns | my $self = shift; | ||
| 376 | 1 | 3µs | "(?:<odur_dur>)"; | ||
| 377 | } | ||||
| 378 | |||||
| 379 | # durations less than a day | ||||
| 380 | sub o_timedurwords { | ||||
| 381 | 2 | 800ns | my $self = shift; | ||
| 382 | "(?:" . join( | ||||
| 383 | "|", | ||||
| 384 | 2 | 13µs | 6 | 6µs | @{ $self->w_hour }, @{ $self->w_minute }, @{ $self->w_second }, # spent 2µs making 2 calls to DateTime::Format::Alami::EN::w_second, avg 1µs/call
# spent 2µs making 2 calls to DateTime::Format::Alami::EN::w_hour, avg 1µs/call
# spent 2µs making 2 calls to DateTime::Format::Alami::EN::w_minute, avg 950ns/call |
| 385 | ) . ")"; | ||||
| 386 | } | ||||
| 387 | |||||
| 388 | # spent 24µs (9+15) within DateTime::Format::Alami::o_timedur which was called:
# once (9µs+15µs) by DateTime::Format::Alami::new at line 61 | ||||
| 389 | 1 | 400ns | my $self = shift; | ||
| 390 | 1 | 6µs | 2 | 16µs | "(?:(" . $self->o_num . "\\s*" . $self->o_timedurwords . "\\s*(?:,\\s*)?)+)"; # spent 15µs making 1 call to DateTime::Format::Alami::o_timedurwords
# spent 700ns making 1 call to DateTime::Format::Alami::EN::o_num |
| 391 | } | ||||
| 392 | |||||
| 393 | sub _parse_dur { | ||||
| 394 | 2 | 1.09ms | 2 | 11.0ms | # spent 10.9ms (1.25+9.69) within DateTime::Format::Alami::BEGIN@394 which was called:
# once (1.25ms+9.69ms) by Role::Tiny::_load_module at line 394 # spent 10.9ms making 1 call to DateTime::Format::Alami::BEGIN@394
# spent 82µs making 1 call to experimental::import |
| 395 | |||||
| 396 | my ($self, $str) = @_; | ||||
| 397 | |||||
| 398 | #say "D:dur=$str"; | ||||
| 399 | my %args; | ||||
| 400 | unless ($self->{_cache_re_parse_dur}) { | ||||
| 401 | my $o_num = $self->o_num; | ||||
| 402 | my $o_dw = $self->o_durwords; | ||||
| 403 | $self->{_cache_re_parse_dur} = qr/($o_num)\s*($o_dw)/ix; | ||||
| 404 | } | ||||
| 405 | unless ($self->{_cache_w_second}) { | ||||
| 406 | $self->{_cache_w_second} = $self->w_second; | ||||
| 407 | $self->{_cache_w_minute} = $self->w_minute; | ||||
| 408 | $self->{_cache_w_hour} = $self->w_hour; | ||||
| 409 | $self->{_cache_w_day} = $self->w_day; | ||||
| 410 | $self->{_cache_w_week} = $self->w_week; | ||||
| 411 | $self->{_cache_w_month} = $self->w_month; | ||||
| 412 | $self->{_cache_w_year} = $self->w_year; | ||||
| 413 | } | ||||
| 414 | while ($str =~ /$self->{_cache_re_parse_dur}/g) { | ||||
| 415 | my ($n, $unit) = ($1, $2); | ||||
| 416 | $n = $self->_parse_num($n); | ||||
| 417 | if ($unit ~~ $self->{_cache_w_second}) { | ||||
| 418 | $args{seconds} = $n; | ||||
| 419 | $self->{_uses_time} = 1; | ||||
| 420 | } elsif ($unit ~~ $self->{_cache_w_minute}) { | ||||
| 421 | $args{minutes} = $n; | ||||
| 422 | $self->{_uses_time} = 1; | ||||
| 423 | } elsif ($unit ~~ $self->{_cache_w_hour}) { | ||||
| 424 | $args{hours} = $n; | ||||
| 425 | $self->{_uses_time} = 1; | ||||
| 426 | } elsif ($unit ~~ $self->{_cache_w_day}) { | ||||
| 427 | $args{days} = $n; | ||||
| 428 | } elsif ($unit ~~ $self->{_cache_w_week}) { | ||||
| 429 | $args{weeks} = $n; | ||||
| 430 | } elsif ($unit ~~ $self->{_cache_w_month}) { | ||||
| 431 | $args{months} = $n; | ||||
| 432 | } elsif ($unit ~~ $self->{_cache_w_year}) { | ||||
| 433 | $args{years} = $n; | ||||
| 434 | } | ||||
| 435 | } | ||||
| 436 | DateTime::Duration->new(%args); | ||||
| 437 | } | ||||
| 438 | |||||
| 439 | sub _now_if_unset { | ||||
| 440 | my $self = shift; | ||||
| 441 | $self->a_now unless $self->{_dt}; | ||||
| 442 | } | ||||
| 443 | |||||
| 444 | sub _today_if_unset { | ||||
| 445 | my $self = shift; | ||||
| 446 | $self->a_today unless $self->{_dt}; | ||||
| 447 | } | ||||
| 448 | |||||
| 449 | sub a_now { | ||||
| 450 | my $self = shift; | ||||
| 451 | $self->{_dt} = DateTime->now( | ||||
| 452 | (time_zone => $self->{time_zone}) x !!defined($self->{time_zone}), | ||||
| 453 | ); | ||||
| 454 | $self->{_uses_time} = 1; | ||||
| 455 | } | ||||
| 456 | |||||
| 457 | # spent 901ms (11.4+890) within DateTime::Format::Alami::a_today which was called 3000 times, avg 300µs/call:
# 3000 times (11.4ms+890ms) by DateTime::Format::Alami::a_dateymd at line 479, avg 300µs/call | ||||
| 458 | 3000 | 533µs | my $self = shift; | ||
| 459 | $self->{_dt} = DateTime->today( | ||||
| 460 | 3000 | 6.95ms | 3000 | 890ms | (time_zone => $self->{time_zone}) x !!defined($self->{time_zone}), # spent 890ms making 3000 calls to DateTime::today, avg 297µs/call |
| 461 | ); | ||||
| 462 | 3000 | 3.95ms | $self->{_uses_time} = 0; | ||
| 463 | } | ||||
| 464 | |||||
| 465 | sub a_yesterday { | ||||
| 466 | my $self = shift; | ||||
| 467 | $self->a_today; | ||||
| 468 | $self->{_dt}->subtract(days => 1); | ||||
| 469 | } | ||||
| 470 | |||||
| 471 | sub a_tomorrow { | ||||
| 472 | my $self = shift; | ||||
| 473 | $self->a_today; | ||||
| 474 | $self->{_dt}->add(days => 1); | ||||
| 475 | } | ||||
| 476 | |||||
| 477 | # spent 2.32s (26.2ms+2.29) within DateTime::Format::Alami::a_dateymd which was called 3000 times, avg 772µs/call:
# 3000 times (26.2ms+2.29s) by DateTime::Format::Alami::CORE:match at line 1 of (eval 6)[lib/DateTime/Format/Alami.pm:115], avg 772µs/call | ||||
| 478 | 3000 | 998µs | my ($self, $m) = @_; | ||
| 479 | 3000 | 2.18ms | 3000 | 901ms | $self->a_today; # spent 901ms making 3000 calls to DateTime::Format::Alami::a_today, avg 300µs/call |
| 480 | 3000 | 811µs | if (defined $m->{o_yearint}) { | ||
| 481 | my $year; | ||||
| 482 | if (length($m->{o_yearint}) == 2) { | ||||
| 483 | my $start_of_century_year = int($self->{_dt}->year / 100) * 100; | ||||
| 484 | $year = $start_of_century_year + $m->{o_yearint}; | ||||
| 485 | } else { | ||||
| 486 | $year = $m->{o_yearint}; | ||||
| 487 | } | ||||
| 488 | $self->{_dt}->set_year($year); | ||||
| 489 | } | ||||
| 490 | 3000 | 3.67ms | 3000 | 698ms | if (defined $m->{o_dayint}) { # spent 698ms making 3000 calls to DateTime::set_day, avg 233µs/call |
| 491 | $self->{_dt}->set_day($m->{o_dayint}); | ||||
| 492 | } | ||||
| 493 | 3000 | 1.00ms | if (defined $m->{o_monthint}) { | ||
| 494 | $self->{_dt}->set_month($m->{o_monthint}); | ||||
| 495 | } | ||||
| 496 | 3000 | 7.19ms | if (defined $m->{o_monthname}) { | ||
| 497 | 2 | 89µs | 2 | 54µs | # spent 33µs (12+21) within DateTime::Format::Alami::BEGIN@497 which was called:
# once (12µs+21µs) by Role::Tiny::_load_module at line 497 # spent 33µs making 1 call to DateTime::Format::Alami::BEGIN@497
# spent 21µs making 1 call to strict::unimport |
| 498 | 3000 | 4.74ms | my $maps = ${ ref($self) . '::MAPS' }; | ||
| 499 | 3000 | 5.64ms | 3000 | 691ms | $self->{_dt}->set_month($maps->{months}{lc $m->{o_monthname}}); # spent 691ms making 3000 calls to DateTime::set_month, avg 230µs/call |
| 500 | } | ||||
| 501 | } | ||||
| 502 | |||||
| 503 | sub a_which_dow { | ||||
| 504 | 2 | 502µs | 2 | 27µs | # spent 18µs (8+10) within DateTime::Format::Alami::BEGIN@504 which was called:
# once (8µs+10µs) by Role::Tiny::_load_module at line 504 # spent 18µs making 1 call to DateTime::Format::Alami::BEGIN@504
# spent 10µs making 1 call to strict::unimport |
| 505 | |||||
| 506 | my ($self, $m) = @_; | ||||
| 507 | $self->a_today; | ||||
| 508 | my $dow_num = $self->{_dt}->day_of_week; | ||||
| 509 | |||||
| 510 | my $maps = ${ ref($self) . '::MAPS' }; | ||||
| 511 | my $wanted_dow_num = $maps->{dow}{lc $m->{o_dow} }; | ||||
| 512 | |||||
| 513 | $self->{_dt}->add(days => ($wanted_dow_num-$dow_num)); | ||||
| 514 | |||||
| 515 | if ($m->{offset}) { | ||||
| 516 | $self->{_dt}->add(days => (7*$m->{offset})); | ||||
| 517 | } | ||||
| 518 | } | ||||
| 519 | |||||
| 520 | sub adur_dur { | ||||
| 521 | my ($self, $m) = @_; | ||||
| 522 | $self->{_dtdur} = $self->_parse_dur($m->{odur_dur}); | ||||
| 523 | } | ||||
| 524 | |||||
| 525 | sub a_dur_ago { | ||||
| 526 | my ($self, $m) = @_; | ||||
| 527 | $self->a_now; | ||||
| 528 | my $dur = $self->_parse_dur($m->{o_dur}); | ||||
| 529 | $self->{_dt}->subtract_duration($dur); | ||||
| 530 | } | ||||
| 531 | |||||
| 532 | sub a_dur_later { | ||||
| 533 | my ($self, $m) = @_; | ||||
| 534 | $self->a_now; | ||||
| 535 | my $dur = $self->_parse_dur($m->{o_dur}); | ||||
| 536 | $self->{_dt}->add_duration($dur); | ||||
| 537 | } | ||||
| 538 | |||||
| 539 | sub a_time { | ||||
| 540 | my ($self, $m) = @_; | ||||
| 541 | $self->_now_if_unset; | ||||
| 542 | $self->{_uses_time} = 1; | ||||
| 543 | my $hour = $m->{o_hour}; | ||||
| 544 | if ($m->{o_ampm}) { | ||||
| 545 | $hour += 12 if lc($m->{o_ampm}) eq 'pm' && $hour < 12; | ||||
| 546 | $hour = 0 if lc($m->{o_ampm}) eq 'am' && $hour == 12; | ||||
| 547 | } | ||||
| 548 | $self->{_dt}->set_hour($hour); | ||||
| 549 | $self->{_dt}->set_minute($m->{o_minute}); | ||||
| 550 | $self->{_dt}->set_second($m->{o_second} // 0); | ||||
| 551 | } | ||||
| 552 | |||||
| 553 | sub a_date_time { | ||||
| 554 | my ($self, $m) = @_; | ||||
| 555 | } | ||||
| 556 | |||||
| 557 | 1 | 12µs | 1; | ||
| 558 | # ABSTRACT: Parse human date/time expression (base class) | ||||
| 559 | |||||
| 560 | =for Pod::Coverage ^((adur|a|pdur|p|odur|o|w)_.+)$ | ||||
| 561 | |||||
| 562 | =head1 SYNOPSIS | ||||
| 563 | |||||
| 564 | For English: | ||||
| 565 | |||||
| 566 | use DateTime::Format::Alami::EN; | ||||
| 567 | my $parser = DateTime::Format::Alami::EN->new(); | ||||
| 568 | my $dt = $parser->parse_datetime("2 hours 13 minutes from now"); | ||||
| 569 | |||||
| 570 | Or you can also call as class method: | ||||
| 571 | |||||
| 572 | my $dt = DateTime::Format::Alami::EN->parse_datetime("yesterday"); | ||||
| 573 | |||||
| 574 | To parse duration: | ||||
| 575 | |||||
| 576 | my $dtdur = DateTime::Format::Alami::EN->parse_datetime_duration("2h"); # 2 hours | ||||
| 577 | |||||
| 578 | For Indonesian: | ||||
| 579 | |||||
| 580 | use DateTime::Format::Alami::ID; | ||||
| 581 | my $parser = DateTime::Format::Alami::ID->new(); | ||||
| 582 | my $dt = $parser->parse_datetime("5 jam lagi"); | ||||
| 583 | |||||
| 584 | Or you can also call as class method: | ||||
| 585 | |||||
| 586 | my $dt = DateTime::Format::Alami::ID->parse_datetime("hari ini"); | ||||
| 587 | |||||
| 588 | To parse duration: | ||||
| 589 | |||||
| 590 | my $dtdur = DateTime::Format::Alami::ID->parse_datetime_duration("2h"); # 2 days | ||||
| 591 | |||||
| 592 | |||||
| 593 | =head1 DESCRIPTION | ||||
| 594 | |||||
| 595 | This class parses human/natural date/time/duration string and returns | ||||
| 596 | L<DateTime> (or L<DateTime::Duration>) object. Currently it supports English and | ||||
| 597 | Indonesian. The goal of this module is to make it easier to add support for | ||||
| 598 | other human languages. | ||||
| 599 | |||||
| 600 | To actually use this class, you must use one of its subclasses for each | ||||
| 601 | human language that you want to parse. | ||||
| 602 | |||||
| 603 | There are already some other DateTime human language parsers on CPAN and | ||||
| 604 | elsewhere, see L</"SEE ALSO">. | ||||
| 605 | |||||
| 606 | |||||
| 607 | =head1 HOW IT WORKS | ||||
| 608 | |||||
| 609 | L<DateTime::Format::Alami> is base class. Each human language is implemented in | ||||
| 610 | a separate C<< DateTime::Format::Alami::<ISO_CODE> >> module (e.g. | ||||
| 611 | L<DateTime::Format::Alami::EN> and L<DateTime::Format::Alami::EN>) which is a | ||||
| 612 | subclass. | ||||
| 613 | |||||
| 614 | Parsing is done using a single recursive regex (i.e. containing C<(?&NAME)> and | ||||
| 615 | C<(?(DEFINE))> patterns, see L<perlre>). This regex is composed from pieces of | ||||
| 616 | pattern strings in the C<p_*> and C<o_*> methods, to make it easier to override | ||||
| 617 | in an OO-fashion. | ||||
| 618 | |||||
| 619 | A pattern string that is returned by the C<p_*> method is a normal regex pattern | ||||
| 620 | string that will be compiled using the /x and /i regex modifier. The pattern | ||||
| 621 | string can also refer to pattern in other C<o_*> or C<p_*> method using syntax | ||||
| 622 | C<< <o_foo> >> or C<< <p_foo> >>. Example, C<o_today> for English might be | ||||
| 623 | something like: | ||||
| 624 | |||||
| 625 | sub p_today { "(?: today | this \s+ day )" } | ||||
| 626 | |||||
| 627 | Other examples: | ||||
| 628 | |||||
| 629 | sub p_yesterday { "(?: yesterday )" } | ||||
| 630 | |||||
| 631 | sub p_dateymd { join( | ||||
| 632 | "", | ||||
| 633 | '(?: <o_dayint> \\s* ?<o_monthname> | <o_monthname> \\s* <o_dayint>\\b|<o_monthint>[ /-]<o_dayint>\\b )', | ||||
| 634 | '(?: \\s*[,/-]?\\s* <o_yearint>)?' | ||||
| 635 | )} | ||||
| 636 | |||||
| 637 | sub o_date { "(?: <p_today>|<p_yesterday>|<p_dateymd>)" } | ||||
| 638 | |||||
| 639 | sub p_time { "(?: <o_hour>:<o_minute>(?:<o_second>)? \s* <o_ampm> )" } | ||||
| 640 | |||||
| 641 | sub p_date_time { "(?: <o_date> (?:\s+ at)? <o_time> )" } | ||||
| 642 | |||||
| 643 | When a pattern from C<p_*> matches, a corresponding action method C<a_*> will be | ||||
| 644 | invoked. Usually the method will set or modify a DateTime object in C<< | ||||
| 645 | $self->{_dt} >>. For example, this is code for C<a_today>: | ||||
| 646 | |||||
| 647 | sub a_today { | ||||
| 648 | my $self = shift; | ||||
| 649 | $self->{_dt} = DateTime->today; | ||||
| 650 | } | ||||
| 651 | |||||
| 652 | The patterns from all C<p_*> methods will be combined in an alternation to form | ||||
| 653 | the final pattern. | ||||
| 654 | |||||
| 655 | An C<o_*> pattern is just like C<p_*>, but they will not be | ||||
| 656 | combined into the final pattern and matching it won't execute a corresponding | ||||
| 657 | C<a_*> method. | ||||
| 658 | |||||
| 659 | And there are also C<w_*> methods which return array of strings. | ||||
| 660 | |||||
| 661 | Parsing duration is similar, except the method names are C<pdur_*>, C<odur_*> | ||||
| 662 | and C<adur_*>. | ||||
| 663 | |||||
| 664 | |||||
| 665 | =head1 ADDING A NEW HUMAN LANGUAGE | ||||
| 666 | |||||
| 667 | See an example in existing C<DateTime::Format::Alami::*> module. Basically you | ||||
| 668 | just need to supply the necessary patterns in the C<p_*> methods. If you want to | ||||
| 669 | introduce new C<p_*> method, don't forget to supply the action too in the C<a_*> | ||||
| 670 | method. | ||||
| 671 | |||||
| 672 | |||||
| 673 | =head1 METHODS | ||||
| 674 | |||||
| 675 | =head2 new => obj | ||||
| 676 | |||||
| 677 | Constructor. You actually must instantiate subclass instead. | ||||
| 678 | |||||
| 679 | =head2 parse_datetime($str[ , \%opts ]) => obj | ||||
| 680 | |||||
| 681 | Parse/extract date/time expression in C<$str>. Die if expression cannot be | ||||
| 682 | parsed. Otherwise return L<DateTime> object (or string/number if C<format> | ||||
| 683 | option is C<verbatim>/C<epoch>, or hash if C<format> option is C<combined>) or | ||||
| 684 | array of objects/strings/numbers (if C<returns> option is C<all>/C<all_cron>). | ||||
| 685 | |||||
| 686 | Known options: | ||||
| 687 | |||||
| 688 | =over | ||||
| 689 | |||||
| 690 | =item * time_zone => str | ||||
| 691 | |||||
| 692 | Will be passed to DateTime constructor. | ||||
| 693 | |||||
| 694 | =item * format => str (DateTime|verbatim|epoch|combined) | ||||
| 695 | |||||
| 696 | The default is C<DateTime>, which will return DateTime object. Other choices | ||||
| 697 | include C<verbatim> (returns the original text), C<epoch> (returns Unix | ||||
| 698 | timestamp), C<combined> (returns a hash containing keys like C<DateTime>, | ||||
| 699 | C<verbatim>, C<epoch>, and other extra information: C<pos> [position of pattern | ||||
| 700 | in the string], C<pattern> [pattern name], C<m> [raw named capture groups], | ||||
| 701 | C<uses_time> [whether the date involves time of day]). | ||||
| 702 | |||||
| 703 | You might think that choosing C<epoch> or C<verbatim> could avoid the overhead | ||||
| 704 | of DateTime, but actually you can't since DateTime is used as the primary format | ||||
| 705 | during parsing. The epoch is retrieved from the DateTime object using the | ||||
| 706 | C<epoch> method. | ||||
| 707 | |||||
| 708 | =item * prefers => str (nearest|future|past) | ||||
| 709 | |||||
| 710 | NOT YET IMPLEMENTED. | ||||
| 711 | |||||
| 712 | This option decides what happens when an ambiguous date appears in the input. | ||||
| 713 | For example, "Friday" may refer to any number of Fridays. Possible choices are: | ||||
| 714 | C<nearest> (prefer the nearest date, the default), C<future> (prefer the closest | ||||
| 715 | future date), C<past> (prefer the closest past date). | ||||
| 716 | |||||
| 717 | =item * returns => str (first|last|earliest|latest|all|all_cron) | ||||
| 718 | |||||
| 719 | If the text has multiple possible dates, then this argument determines which | ||||
| 720 | date will be returned. Possible choices are: C<first> (return the first date | ||||
| 721 | found in the string, the default), C<last> (return the final date found in the | ||||
| 722 | string), C<earliest> (return the date found in the string that chronologically | ||||
| 723 | precedes any other date in the string), C<latest> (return the date found in the | ||||
| 724 | string that chronologically follows any other date in the string), C<all> | ||||
| 725 | (return all dates found in the string, in the order they were found in the | ||||
| 726 | string), C<all_cron> (return all dates found in the string, in chronological | ||||
| 727 | order). | ||||
| 728 | |||||
| 729 | When C<all> or C<all_cron> is chosen, function will return array(ref) of results | ||||
| 730 | instead of a single result, even if there is only a single actual result. | ||||
| 731 | |||||
| 732 | =back | ||||
| 733 | |||||
| 734 | =head2 parse_datetime_duration($str[ , \%opts ]) => obj | ||||
| 735 | |||||
| 736 | Parse/extract duration expression in C<$str>. Die if expression cannot be | ||||
| 737 | parsed. Otherwise return L<DateTime::Duration> object (or string/number if | ||||
| 738 | C<format> option is C<verbatim>/C<seconds>, or hash if C<format> option is | ||||
| 739 | C<combined>) or array of objects/strings/numbers (if C<returns> option is | ||||
| 740 | C<all>/C<all_sorted>). | ||||
| 741 | |||||
| 742 | Known options: | ||||
| 743 | |||||
| 744 | =over | ||||
| 745 | |||||
| 746 | =item * format => str (Duration|verbatim|seconds|combined) | ||||
| 747 | |||||
| 748 | The default is C<Duration>, which will return DateTime::Duration object. Other | ||||
| 749 | choices include C<verbatim> (returns the original text), C<seconds> (returns | ||||
| 750 | number of seconds, approximated), C<combined> (returns a hash containing keys | ||||
| 751 | like C<Duration>, C<verbatim>, C<seconds>, and other extra information: C<pos> | ||||
| 752 | [position of pattern in the string], C<pattern> [pattern name], C<m> [raw named | ||||
| 753 | capture groups]). | ||||
| 754 | |||||
| 755 | You might think that choosing C<seconds> or C<verbatim> could avoid the overhead | ||||
| 756 | of DateTime::Duration, but actually you can't since DateTime::Duration is used | ||||
| 757 | as the primary format during parsing. The number of seconds is calculated from | ||||
| 758 | the DateTime::Duration object I<using an approximation> (for example, "1 month" | ||||
| 759 | does not convert exactly to seconds). | ||||
| 760 | |||||
| 761 | =item * returns => str (first|last|smallest|largest|all|all_sorted) | ||||
| 762 | |||||
| 763 | If the text has multiple possible durations, then this argument determines which | ||||
| 764 | date will be returned. Possible choices are: C<first> (return the first duration | ||||
| 765 | found in the string, the default), C<last> (return the final duration found in | ||||
| 766 | the string), C<smallest> (return the smallest duration), C<largest> (return the | ||||
| 767 | largest duration), C<all> (return all durations found in the string, in the | ||||
| 768 | order they were found in the string), C<all_sorted> (return all durations found | ||||
| 769 | in the string, in smallest-to-largest order). | ||||
| 770 | |||||
| 771 | When C<all> or C<all_sorted> is chosen, function will return array(ref) of | ||||
| 772 | results instead of a single result, even if there is only a single actual | ||||
| 773 | result. | ||||
| 774 | |||||
| 775 | =back | ||||
| 776 | |||||
| 777 | |||||
| 778 | =head1 FAQ | ||||
| 779 | |||||
| 780 | =head2 What does "alami" mean? | ||||
| 781 | |||||
| 782 | It is an Indonesian word, meaning "natural". | ||||
| 783 | |||||
| 784 | =head2 How does it compare to similar modules? | ||||
| 785 | |||||
| 786 | L<DateTime::Format::Natural> (DF:Natural) is a more established module (first | ||||
| 787 | released on 2006) and can understand a bit more English expression like 'last | ||||
| 788 | day of Sep'. Aside from English, it does not yet support other languages. | ||||
| 789 | |||||
| 790 | DFA:EN's C<parse_datetime_duration()> produces a L<DateTime::Duration> object | ||||
| 791 | while DF:Natural's C<parse_datetime_duration()> returns two L<DateTime> objects | ||||
| 792 | instead. In other words, DF:Natural can parse "from 23 Jun to 29 Jun" in | ||||
| 793 | addition to "for 2 weeks". | ||||
| 794 | |||||
| 795 | DF:Natural in general is slightly more strict about the formats it accepts, e.g. | ||||
| 796 | it rejects C<Jun 23st> (the error message even gives hints that the suffix must | ||||
| 797 | be 'rd'). DF:Natural can give a detailed error message on why parsing has failed | ||||
| 798 | (see its C<error()> method). | ||||
| 799 | |||||
| 800 | L<DateTime::Format::Flexible> (DF:Flexible) is another established module (first | ||||
| 801 | released in 2007) that, aside from parsing human expression (like 'tomorrow', | ||||
| 802 | 'sep 1st') can also parse date/time in several other formats like RFC 822, | ||||
| 803 | making it a convenient module to use as a 'one-stop' solution to parse date. | ||||
| 804 | Compared to DF:Natural, it has better support for timezone but cannot parse some | ||||
| 805 | English expressions. Aside from English, it currently supports German and | ||||
| 806 | Spanish. It does not support parsing duration expression. Performance-wise, it | ||||
| 807 | is the slowest (see L<Bencher::Scenario::DateTimeFormatAlami::Parsing>). | ||||
| 808 | |||||
| 809 | This module itself: B<DateTime::Format::Alami> (DF:Alami) is yet another | ||||
| 810 | implementation. Internally, it uses recursive regex to make parsing simpler and | ||||
| 811 | adding more languages easier. It requires perl 5.14.0 or newer due to the use of | ||||
| 812 | C<(?{ ... })> code blocks inside regular expression (while DF:Natural and | ||||
| 813 | DF:Flexible can run on perl 5.8+). It currently supports English and Indonesian. | ||||
| 814 | It supports parsing duration expression and returns DateTime::Duration object. | ||||
| 815 | It has the smallest startup time (see see | ||||
| 816 | L<Bencher::Scenario::DateTimeFormatAlami::Startup>). | ||||
| 817 | |||||
| 818 | |||||
| 819 | =head1 SEE ALSO | ||||
| 820 | |||||
| 821 | =head2 Similar modules on CPAN | ||||
| 822 | |||||
| 823 | L<Date::Extract>. DateTime::Format::Alami has some features of Date::Extract so | ||||
| 824 | it can be used to replace Date::Extract. | ||||
| 825 | |||||
| 826 | L<DateTime::Format::Flexible>. See L</"FAQ">. | ||||
| 827 | |||||
| 828 | For Indonesian: L<DateTime::Format::Indonesian>, L<Date::Extract::ID> (currently | ||||
| 829 | this module uses DateTime::Format::Alami::ID as its backend). | ||||
| 830 | |||||
| 831 | For English: L<DateTime::Format::Natural>. See L</"FAQ">. | ||||
| 832 | |||||
| 833 | |||||
| 834 | =head2 Other modules on CPAN | ||||
| 835 | |||||
| 836 | L<DateTime::Format::Human> deals with formatting and not parsing. | ||||
| 837 | |||||
| 838 | =head2 Similar non-Perl libraries | ||||
| 839 | |||||
| 840 | Natt Java library, which the last time I tried sometimes gives weird answer, | ||||
| 841 | e.g. "32 Oct" becomes 1 Oct in the far future. http://natty.joestelmach.com/ | ||||
| 842 | |||||
| 843 | Duckling Clojure library, which can parse date/time as well as numbers with some | ||||
| 844 | other units like temperature. https://github.com/wit-ai/duckling | ||||
| 845 | |||||
| 846 | =cut | ||||
# spent 2.38s (67.9ms+2.32) within DateTime::Format::Alami::CORE:match which was called 4246 times, avg 562µs/call:
# 2000 times (1.35ms+0s) by DateTime::Format::Alami::parse_datetime at line 225, avg 675ns/call
# 1000 times (66.2ms+2.32s) by DateTime::Format::Alami::__ANON__[(eval 12)[lib/DateTime/Format/Alami.pm:180]:1] at line 1 of (eval 12)[lib/DateTime/Format/Alami.pm:180], avg 2.38ms/call
# 1000 times (237µs+0s) by DateTime::Format::Alami::parse_datetime at line 209, avg 237ns/call
# 78 times (48µs+0s) by DateTime::Format::Alami::new at line 60, avg 617ns/call
# 28 times (13µs+0s) by DateTime::Format::Alami::new at line 100, avg 468ns/call
# 28 times (12µs+0s) by DateTime::Format::Alami::new at line 62, avg 429ns/call
# 28 times (8µs+0s) by DateTime::Format::Alami::new at line 99, avg 268ns/call
# 28 times (5µs+0s) by DateTime::Format::Alami::new at line 63, avg 189ns/call
# 28 times (5µs+0s) by DateTime::Format::Alami::new at line 110, avg 171ns/call
# 28 times (4µs+0s) by DateTime::Format::Alami::new at line 109, avg 154ns/call | |||||
# spent 16µs within DateTime::Format::Alami::CORE:qr which was called 4 times, avg 4µs/call:
# once (11µs+0s) by DateTime::Format::Alami::CORE:regcomp at line 1 of (eval 6)[lib/DateTime/Format/Alami.pm:115]
# once (3µs+0s) by DateTime::Format::Alami::CORE:regcomp at line 1 of (eval 7)[lib/DateTime/Format/Alami.pm:116]
# once (1µs+0s) by DateTime::Format::Alami::new at line 115
# once (1µs+0s) by DateTime::Format::Alami::new at line 116 | |||||
# spent 2.27ms (2.26+13µs) within DateTime::Format::Alami::CORE:regcomp which was called 3 times, avg 757µs/call:
# once (1.54ms+11µs) by DateTime::Format::Alami::new at line 115
# once (476µs+0s) by DateTime::Format::Alami::__ANON__[(eval 12)[lib/DateTime/Format/Alami.pm:180]:1] at line 1 of (eval 12)[lib/DateTime/Format/Alami.pm:180]
# once (244µs+3µs) by DateTime::Format::Alami::new at line 116 | |||||
# spent 25µs within DateTime::Format::Alami::CORE:sort which was called:
# once (25µs+0s) by DateTime::Format::Alami::new at line 87 | |||||
sub DateTime::Format::Alami::CORE:subst; # opcode | |||||
# spent 36µs within DateTime::Format::Alami::CORE:substcont which was called 33 times, avg 1µs/call:
# 33 times (36µs+0s) by DateTime::Format::Alami::new at line 64, avg 1µs/call |