← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/hailo
  Run on Thu Oct 21 22:50:37 2010
Reported on Thu Oct 21 22:52:12 2010

Filename/mnt/stuff/src/my-cpan/hailo/lib/Hailo/Command.pm
StatementsExecuted 107217 statements in 523ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
250011166.8ms93.5msHailo::Command::::CORE:readlineHailo::Command::CORE:readline (opcode)
14261126.8ms37.9msHailo::Command::::__ANON__[lib/Hailo/Command.pm:325]Hailo::Command::__ANON__[lib/Hailo/Command.pm:325]
1426116.25ms6.25msHailo::Command::::CORE:substHailo::Command::CORE:subst (opcode)
2796114.77ms4.77msHailo::Command::::CORE:substcontHailo::Command::CORE:substcont (opcode)
1112.65ms9.75msHailo::Command::::__ANON__[lib/Hailo/Command.pm:307]Hailo::Command::__ANON__[lib/Hailo/Command.pm:307]
1111.13ms8.63msHailo::Command::::BEGIN@7Hailo::Command::BEGIN@7
111866µs1.39msHailo::Command::::BEGIN@374Hailo::Command::BEGIN@374
11146µs130µsHailo::Command::::BEGIN@3Hailo::Command::BEGIN@3
11123µs51.8sHailo::Command::::__ANON__[lib/Hailo/Command.pm:298]Hailo::Command::__ANON__[lib/Hailo/Command.pm:298]
11119µs47.3msHailo::Command::::__ANON__[lib/Hailo/Command.pm:234]Hailo::Command::__ANON__[lib/Hailo/Command.pm:234]
11115µs85µsHailo::Command::::BEGIN@3.2Hailo::Command::BEGIN@3.2
11113µs6.59msHailo::Command::::__ANON__[lib/Hailo/Command.pm:59]Hailo::Command::__ANON__[lib/Hailo/Command.pm:59]
11112µs35µsHailo::Command::::BEGIN@370Hailo::Command::BEGIN@370
11112µs14µsHailo::Command::::CORE:sayHailo::Command::CORE:say (opcode)
11112µs51.7msHailo::Command::::BEGIN@5Hailo::Command::BEGIN@5
11112µs1.14msHailo::Command::::BEGIN@6Hailo::Command::BEGIN@6
11112µs21µsHailo::Command::::__ANON__[lib/Hailo/Command.pm:154]Hailo::Command::__ANON__[lib/Hailo/Command.pm:154]
11111µs37µsHailo::Command::::BEGIN@242Hailo::Command::BEGIN@242
32211µs12µsHailo::Command::::brainHailo::Command::brain (xsub)
11110µs572µsHailo::Command::::BEGIN@4Hailo::Command::BEGIN@4
3214µs4µsHailo::Command::::_go_trainHailo::Command::_go_train (xsub)
2113µs3µsHailo::Command::::orderHailo::Command::order (xsub)
2113µs3µsHailo::Command::::tokenizer_classHailo::Command::tokenizer_class (xsub)
1112µs2µsHailo::Command::::save_on_exitHailo::Command::save_on_exit (xsub)
1112µs2µsHailo::Command::::_go_learnHailo::Command::_go_learn (xsub)
1112µs2µsHailo::Command::::_go_progressHailo::Command::_go_progress (xsub)
1112µs2µsHailo::Command::::_go_learn_replyHailo::Command::_go_learn_reply (xsub)
1112µs2µsHailo::Command::::_go_versionHailo::Command::_go_version (xsub)
1112µs2µsHailo::Command::::engine_classHailo::Command::engine_class (xsub)
1112µs2µsHailo::Command::::_go_replyHailo::Command::_go_reply (xsub)
1112µs2µsHailo::Command::::_go_statsHailo::Command::_go_stats (xsub)
1111µs1µsHailo::Command::::_go_random_replyHailo::Command::_go_random_reply (xsub)
1111µs1µsHailo::Command::::storage_classHailo::Command::storage_class (xsub)
0000s0sHailo::Command::::__ANON__[lib/Hailo/Command.pm:128]Hailo::Command::__ANON__[lib/Hailo/Command.pm:128]
0000s0sHailo::Command::::__ANON__[lib/Hailo/Command.pm:141]Hailo::Command::__ANON__[lib/Hailo/Command.pm:141]
0000s0sHailo::Command::::__ANON__[lib/Hailo/Command.pm:168]Hailo::Command::__ANON__[lib/Hailo/Command.pm:168]
0000s0sHailo::Command::::__ANON__[lib/Hailo/Command.pm:181]Hailo::Command::__ANON__[lib/Hailo/Command.pm:181]
0000s0sHailo::Command::::__ANON__[lib/Hailo/Command.pm:194]Hailo::Command::__ANON__[lib/Hailo/Command.pm:194]
0000s0sHailo::Command::::__ANON__[lib/Hailo/Command.pm:207]Hailo::Command::__ANON__[lib/Hailo/Command.pm:207]
0000s0sHailo::Command::::_getopt_full_usageHailo::Command::_getopt_full_usage
0000s0sHailo::Command::::_getopt_spec_exceptionHailo::Command::_getopt_spec_exception
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1144µs350µspackage Hailo::Command;
# spent 43µs making 1 call to Encode::utf8::decode_xs # spent 5µs making 1 call to Encode::Encoding::renewed # spent 3µs making 1 call to Encode::utf8::encode_xs
2
34110µs5312µs
# spent 130µs (46+85) within Hailo::Command::BEGIN@3 which was called: # once (46µs+85µs) by hailo::BEGIN@8 at line 3 # spent 85µs (15+70) within Hailo::Command::BEGIN@3.2 which was called: # once (15µs+70µs) by Hailo::Command::BEGIN@3 at line 3
use 5.010;
# spent 130µs making 1 call to Hailo::Command::BEGIN@3 # spent 85µs making 1 call to Hailo::Command::BEGIN@3.2 # spent 70µs making 1 call to feature::import # spent 24µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
4230µs21.13ms
# spent 572µs (10+562) within Hailo::Command::BEGIN@4 which was called: # once (10µs+562µs) by hailo::BEGIN@8 at line 4
use Any::Moose;
# spent 572µs making 1 call to Hailo::Command::BEGIN@4 # spent 562µs making 1 call to Any::Moose::import
5235µs2103ms
# spent 51.7ms (12µs+51.6) within Hailo::Command::BEGIN@5 which was called: # once (12µs+51.6ms) by hailo::BEGIN@8 at line 5
use Any::Moose 'X::Getopt';
# spent 51.7ms making 1 call to Hailo::Command::BEGIN@5 # spent 51.6ms making 1 call to Any::Moose::import
6239µs22.27ms
# spent 1.14ms (12µs+1.13) within Hailo::Command::BEGIN@6 which was called: # once (12µs+1.13ms) by hailo::BEGIN@8 at line 6
use Any::Moose 'X::StrictConstructor';
# spent 1.14ms making 1 call to Hailo::Command::BEGIN@6 # spent 1.13ms making 1 call to Any::Moose::import
72154µs39.92ms
# spent 8.63ms (1.13+7.51) within Hailo::Command::BEGIN@7 which was called: # once (1.13ms+7.51ms) by hailo::BEGIN@8 at line 7
use namespace::clean -except => 'meta';
# spent 8.63ms making 1 call to Hailo::Command::BEGIN@7 # spent 1.28ms making 1 call to namespace::clean::import # spent 4µs making 1 call to Encode::utf8::encode_xs
8
9144µs427.4msextends 'Hailo';
# spent 27.4ms making 1 call to Mouse::extends # spent 30µs making 1 call to Encode::utf8::decode_xs # spent 5µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
10
11153µs58.24mswith any_moose('X::Getopt::Dashes');
# spent 8.13ms making 1 call to Mouse::with # spent 84µs making 1 call to Any::Moose::any_moose # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 5µs making 1 call to Encode::utf8::encode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
12
13133µs330µs## Our internal Getopts method that Hailo.pm doesn't care about.
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
14
15162µs232µs# MooseX::Getopt 81b19ed83c by Karen Etheridge changed the help
# spent 29µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
16# attribute to help_flag.
17{
18219µs395µsmy @go_attrs = any_moose('X::Getopt::GLD')->meta->get_attribute_list;
# spent 76µs making 1 call to Any::Moose::any_moose # spent 14µs making 1 call to MouseX::Getopt::GLD::meta # spent 4µs making 1 call to Mouse::Meta::Module::get_attribute_list
19112µs12µsmy $help_attr = 'help_flag' ~~ @go_attrs ? 'help_flag' : 'help';
# spent 2µs making 1 call to Encode::utf8::encode_xs
20
21168µs3523µshas $help_attr => (
# spent 491µs making 1 call to Mouse::has # spent 29µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
22 traits => [ qw/ Getopt / ],
23 cmd_aliases => 'h',
24 cmd_flag => 'help',
25 isa => 'Bool',
26 is => 'ro',
27 default => 0,
28 documentation => "You're soaking it in",
29);
3012µs}
# spent 2µs making 1 call to Encode::utf8::encode_xs
31
32163µs3497µshas _go_version => (
# spent 468µs making 1 call to Mouse::has # spent 26µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
33 traits => [ qw/ Getopt / ],
34 cmd_aliases => 'v',
35 cmd_flag => 'version',
36 documentation => 'Print version and exit',
37 isa => 'Bool',
38 is => 'ro',
3912µs);
# spent 2µs making 1 call to Encode::utf8::encode_xs
40
41153µs3455µshas _go_examples => (
# spent 427µs making 1 call to Mouse::has # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
42 traits => [ qw/ Getopt / ],
43 cmd_flag => 'examples',
44 documentation => 'Print examples along with the help message',
45 isa => 'Bool',
46 is => 'ro',
4712µs);
# spent 2µs making 1 call to Encode::utf8::encode_xs
48
49179µs233µshas _go_progress => (
# spent 30µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
50 traits => [ qw/ Getopt / ],
51 cmd_aliases => 'p',
52 cmd_flag => 'progress',
53 documentation => 'Display progress during the import',
54 isa => 'Bool',
55 is => 'ro',
56
# spent 6.59ms (13µs+6.58) within Hailo::Command::__ANON__[lib/Hailo/Command.pm:59] which was called: # once (13µs+6.58ms) by Mouse::Object::new at line 78 of MouseX/Getopt/Basic.pm
default => sub {
5712µs my ($self) = @_;
58111µs16.58ms $self->_is_interactive();
# spent 6.58ms making 1 call to Hailo::_is_interactive
59 },
6018µs2483µs);
# spent 481µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
61
62170µs3499µshas _go_learn => (
# spent 469µs making 1 call to Mouse::has # spent 26µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
63 traits => [ qw/ Getopt / ],
64 cmd_aliases => "l",
65 cmd_flag => "learn",
66 documentation => "Learn from STRING",
67 isa => 'Str',
68 is => "ro",
6912µs);
# spent 2µs making 1 call to Encode::utf8::encode_xs
70
71153µs3511µshas _go_learn_reply => (
# spent 480µs making 1 call to Mouse::has # spent 27µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
72 traits => [ qw/ Getopt / ],
73 cmd_aliases => "L",
74 cmd_flag => "learn-reply",
75 documentation => "Learn from STRING and reply to it",
76 isa => 'Str',
77 is => "ro",
7812µs);
# spent 2µs making 1 call to Encode::utf8::encode_xs
79
80156µs3499µshas _go_train => (
# spent 471µs making 1 call to Mouse::has # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
81 traits => [ qw/ Getopt / ],
82 cmd_aliases => "t",
83 cmd_flag => "train",
84 documentation => "Learn from all the lines in FILE, use - for STDIN",
85 isa => 'Str',
86 is => "ro",
8714µs);
# spent 4µs making 1 call to Encode::utf8::encode_xs
88
89154µs3501µshas _go_reply => (
# spent 473µs making 1 call to Mouse::has # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
90 traits => [ qw/ Getopt / ],
91 cmd_aliases => "r",
92 cmd_flag => "reply",
93 documentation => "Reply to STRING",
94 isa => 'Str',
95 is => "ro",
9612µs);
# spent 2µs making 1 call to Encode::utf8::encode_xs
97
98157µs3501µshas _go_random_reply => (
# spent 471µs making 1 call to Mouse::has # spent 27µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
99 traits => [ qw/ Getopt / ],
100 cmd_aliases => "R",
101 cmd_flag => "random-reply",
102 documentation => "Like --reply but takes no STRING; Babble at random",
103 isa => 'Bool',
104 is => "ro",
10512µs);
# spent 2µs making 1 call to Encode::utf8::encode_xs
106
107157µs3495µshas _go_stats => (
# spent 467µs making 1 call to Mouse::has # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
108 traits => [ qw/ Getopt / ],
109 cmd_aliases => "s",
110 cmd_flag => "stats",
111 documentation => "Print statistics about the brain",
112 isa => 'Bool',
113 is => "ro",
11414µs);
# spent 4µs making 1 call to Encode::utf8::encode_xs
115
116133µs331µs## Things we have to pass to Hailo.pm via triggers when they're set
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
117
118179µs228µshas _go_autosave => (
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
119 traits => [ qw/ Getopt / ],
120 cmd_aliases => 'a',
121 cmd_flag => 'autosave',
122 documentation => 'Save the brain on exit (on by default)',
123 isa => 'Bool',
124 is => 'rw',
125 trigger => sub {
126 my ($self, $bool) = @_;
127 $self->save_on_exit($bool);
128 },
129111µs2476µs);
# spent 474µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
130
131176µs225µshas _go_order => (
# spent 22µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
132 traits => [ qw/ Getopt / ],
133 cmd_aliases => "o",
134 cmd_flag => "order",
135 documentation => "Markov order; How deep the rabbit hole goes",
136 isa => 'Int',
137 is => "rw",
138 trigger => sub {
139 my ($self, $order) = @_;
140 $self->order($order);
141 },
14218µs2494µs);
# spent 492µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
143
144184µs223µshas _go_brain => (
# spent 20µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
145 traits => [ qw/ Getopt / ],
146 cmd_aliases => "b",
147 cmd_flag => "brain",
148 documentation => "Load/save brain to/from FILE",
149 isa => 'Str',
150 is => "ro",
151
# spent 21µs (12+9) within Hailo::Command::__ANON__[lib/Hailo/Command.pm:154] which was called: # once (12µs+9µs) by Mouse::Object::new at line 78 of MouseX/Getopt/Basic.pm
trigger => sub {
15212µs my ($self, $brain) = @_;
153119µs210µs $self->brain($brain);
# spent 9µs making 1 call to Hailo::Command::brain # spent 1µs making 1 call to Mouse::Meta::TypeConstraint::_compiled_type_constraint
154 },
15518µs2481µs);
# spent 479µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
156
157122µs222µs# working classes
# spent 19µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
158has _go_engine_class => (
159177µs231µs traits => [ qw/ Getopt / ],
# spent 28µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
160 cmd_aliases => "E",
161 cmd_flag => "engine",
162 isa => 'Str',
163 is => "rw",
164 documentation => "Use engine CLASS",
165 trigger => sub {
166 my ($self, $class) = @_;
167 $self->engine_class($class);
168 },
16918µs2484µs);
# spent 482µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
170
171189µs239µshas _go_storage_class => (
# spent 36µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
172 traits => [ qw/ Getopt / ],
173 cmd_aliases => "S",
174 cmd_flag => "storage",
175 isa => 'Str',
176 is => "rw",
177 documentation => "Use storage CLASS",
178 trigger => sub {
179 my ($self, $class) = @_;
180 $self->storage_class($class);
181 },
18218µs2469µs);
# spent 467µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
183
184182µs231µshas _go_tokenizer_class => (
# spent 27µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
185 traits => [ qw/ Getopt / ],
186 cmd_aliases => "T",
187 cmd_flag => "tokenizer",
188 isa => 'Str',
189 is => "rw",
190 documentation => "Use tokenizer CLASS",
191 trigger => sub {
192 my ($self, $class) = @_;
193 $self->tokenizer_class($class);
194 },
19518µs2470µs);
# spent 468µs making 1 call to Mouse::has # spent 2µs making 1 call to Encode::utf8::encode_xs
196
197188µs231µshas _go_ui_class => (
# spent 28µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
198 traits => [ qw/ Getopt / ],
199 cmd_aliases => "u",
200 cmd_flag => "ui",
201 isa => 'Str',
202 is => "rw",
203 documentation => "Use UI CLASS",
204 trigger => sub {
205 my ($self, $class) = @_;
206 $self->ui_class($class);
207 },
20817µs2482µs);
# spent 477µs making 1 call to Mouse::has # spent 5µs making 1 call to Encode::utf8::encode_xs
209
210174µs227µs# Stop Hailo from polluting our command-line interface
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
21116µsfor (qw/ save_on_exit order brain /, map { qq[${_}_class] } qw/ engine storage tokenizer ui /) {
212740µs76.49ms has "+$_" => (
# spent 6.49ms making 7 calls to Mouse::has, avg 927µs/call
213 traits => [ qw/ NoGetopt / ],
214 );
21515µs}
# spent 5µs making 1 call to Encode::utf8::encode_xs
216
217150µs229µs# Check validity of options
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
218
# spent 47.3ms (19µs+47.3) within Hailo::Command::__ANON__[lib/Hailo/Command.pm:234] which was called: # once (19µs+47.3ms) by Hailo::Command::run at line 330 of Mouse/Meta/Class.pm
before run => sub {
21912µs12µs my ($self) = @_;
# spent 2µs making 1 call to Encode::utf8::encode_xs
220
2211129µs894.6ms if (not $self->_storage->ready and
# spent 47.3ms making 1 call to Hailo::_storage # spent 47.1ms making 1 call to Hailo::__ANON__[lib/Hailo.pm:170] # spent 118µs making 1 call to Mouse::Util::TypeConstraints::__ANON__[Mouse/Util/TypeConstraints.pm:217] # spent 29µs making 1 call to Hailo::Storage::SQLite::ready # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Mouse::Meta::Attribute::builder # spent 2µs making 1 call to Mouse::Meta::TypeConstraint::_compiled_type_constraint
222 (defined $self->_go_reply or
223 defined $self->_go_train or
224 defined $self->_go_learn or
225 defined $self->_go_learn_reply or
226 defined $self->_go_random_reply)) {
227 # TODO: Make this spew out the --help reply just like hailo
228 # with invalid options does usually, but only if run via
229 # ->new_with_options
230 die "To reply/train/learn you must specify options to initialize your storage backend";
23112µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
232
233171µs246µs return;
# spent 40µs making 1 call to Encode::utf8::decode_xs # spent 6µs making 1 call to Encode::Encoding::renewed
23417µs2106µs};
# spent 100µs making 1 call to Mouse::before # spent 5µs making 1 call to Encode::utf8::encode_xs
235
236144µs228µssub run {
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
23712µs12µs my ($self) = @_;
# spent 2µs making 1 call to Encode::utf8::encode_xs
238
239170µs344µs if ($self->_go_version) {
# spent 39µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Hailo::Command::_go_version
240 # Munging strictness because we don't have a version from a
241 # Git checkout. Dist::Zilla provides it.
242237µs262µs
# spent 37µs (11+25) within Hailo::Command::BEGIN@242 which was called: # once (11µs+25µs) by hailo::BEGIN@8 at line 242
no strict 'vars';
# spent 37µs making 1 call to Hailo::Command::BEGIN@242 # spent 26µs making 1 call to strict::unimport
24312µs my $version = $VERSION // 'dev-git';
# spent 2µs making 1 call to Encode::utf8::encode_xs
244
245144µs229µs say "hailo $version";
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
246 return;
24712µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
248
2491114µs6117µs if ($self->_is_interactive() and
# spent 67µs making 1 call to Hailo::_is_interactive # spent 26µs making 1 call to Encode::utf8::decode_xs # spent 18µs making 1 call to Hailo::Storage::SQLite::ready # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Hailo::Command::_go_train # spent 2µs making 1 call to Hailo::_storage
250 $self->_storage->ready and
251 not defined $self->_go_train and
252 not defined $self->_go_learn and
253 not defined $self->_go_reply and
254 not defined $self->_go_learn_reply and
255 not defined $self->_go_stats and
256 not defined $self->_go_random_reply) {
257 $self->_ui->run($self);
25812µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
259
260168µs551.9s $self->train($self->_go_train) if defined $self->_go_train;
# spent 51.9s making 1 call to Hailo::train # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 3µs making 2 calls to Hailo::Command::_go_train, avg 1µs/call
261111µs24µs $self->learn($self->_go_learn) if defined $self->_go_learn;
# spent 2µs making 1 call to Hailo::Command::_go_learn # spent 2µs making 1 call to Encode::utf8::encode_xs
262
263172µs339µs if (defined $self->_go_learn_reply) {
# spent 34µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Hailo::Command::_go_learn_reply
264 my $answer = $self->learn_reply($self->_go_learn_reply);
265 say $answer // "I don't know enough to answer you yet.";
26612µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
267
268197µs431µs if (defined $self->_go_random_reply) {
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Hailo::Command::_go_reply # spent 1µs making 1 call to Hailo::Command::_go_random_reply
269 my $answer = $self->reply();
270 say $answer // "I don't know enough to answer you yet.";
271 }
272 elsif (defined $self->_go_reply) {
273 my $answer = $self->reply($self->_go_reply);
274 say $answer // "I don't know enough to answer you yet.";
27512µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
276
277198µs326µs if ($self->_go_stats) {
# spent 21µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Hailo::Command::_go_stats
278 my ($tok, $ex, $prev, $next) = $self->stats();
279 my $order = $self->_storage->order;
280 say "Tokens: $tok";
281 say "Expression length: $order tokens";
282 say "Expressions: $ex";
283 say "Links to preceding tokens: $prev";
284 say "Links to following tokens: $next";
28512µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
286
287152µs220µs return;
# spent 17µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
28812µs}
# spent 2µs making 1 call to Encode::utf8::encode_xs
289
290140µs221µs
# spent 51.8s (23µs+51.8) within Hailo::Command::__ANON__[lib/Hailo/Command.pm:298] which was called: # once (23µs+51.8s) by Hailo::Command::_train_fh at line 416 of Mouse/Meta/Class.pm
override _train_fh => sub {
# spent 17µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
29112µs12µs my ($self, $fh, $filename) = @_;
# spent 2µs making 1 call to Encode::utf8::encode_xs
292
293187µs551.8s if ($self->_go_progress and $self->_is_interactive) {
# spent 51.8s making 1 call to Hailo::Command::train_progress # spent 68µs making 1 call to Hailo::_is_interactive # spent 14µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Hailo::Command::_go_progress
294 $self->train_progress($fh, $filename);
295 } else {
296 super();
297 }
298110µs281µs};
# spent 79µs making 1 call to Mouse::override # spent 2µs making 1 call to Encode::utf8::encode_xs
299
300148µs216µs
# spent 9.75ms (2.65+7.10) within Hailo::Command::__ANON__[lib/Hailo/Command.pm:307] which was called: # once (2.65ms+7.10ms) by Hailo::Command::train_progress at line 330 of Mouse/Meta/Class.pm
before train_progress => sub {
# spent 13µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
3011148µs require Term::Sk;
3021117µs require File::CountLines;
30315µs166µs File::CountLines->import('count_lines');
# spent 66µs making 1 call to Exporter::import
30412µs require Time::HiRes;
305166µs3192µs Time::HiRes->import(qw(gettimeofday tv_interval));
# spent 162µs making 1 call to Time::HiRes::import # spent 26µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
30615µs return;
30718µs295µs};
# spent 93µs making 1 call to Mouse::before # spent 2µs making 1 call to Encode::utf8::encode_xs
308
3091145µs229µssub train_progress {
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
31012µs my ($self, $fh, $filename) = @_;
31114µs12.49ms my $lines = count_lines($filename);
# spent 2.49ms making 1 call to File::CountLines::count_lines
312 my $progress = Term::Sk->new('%d Elapsed: %8t %21b %4p %2d (%c of %m)', {
313 # Start at line 1, not 0
314 base => 1,
315 target => $lines,
316 # Every 0.1 seconds for long files
317 freq => ($lines < 10_000 ? 10 : 'd'),
318 # Override Term::Sk's default 100_100 to 100,000
319
# spent 37.9ms (26.8+11.0) within Hailo::Command::__ANON__[lib/Hailo/Command.pm:325] which was called 1426 times, avg 27µs/call: # 1426 times (26.8ms+11.0ms) by Term::Sk::commify at line 260 of Term/Sk.pm, avg 27µs/call
commify => sub {
32014261.57ms my $int = shift;
32114262.51ms $int = reverse $int;
322142626.2ms422211.0ms $int =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g;
# spent 6.25ms making 1426 calls to Hailo::Command::CORE:subst, avg 4µs/call # spent 4.77ms making 2796 calls to Hailo::Command::CORE:substcont, avg 2µs/call
32314262.16ms $int = reverse $int;
32414265.63ms return $int;
325 },
326114µs2600µs }) or die "Error in Term::Sk->new: (code $Term::Sk::errcode) $Term::Sk::errmsg";
# spent 597µs making 1 call to Term::Sk::new # spent 2µs making 1 call to Encode::utf8::encode_xs
327
328150µs230µs my $next_update = 0;
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
329112µs211µs my $start_time = [gettimeofday()];
# spent 6µs making 1 call to Time::HiRes::gettimeofday # spent 5µs making 1 call to Encode::utf8::encode_xs
330
3312202ms26547124ms my $i = 0; while (my $line = <$fh>) {
# spent 93.5ms making 25001 calls to Hailo::Command::CORE:readline, avg 4µs/call # spent 26.7ms making 773 calls to Encode::utf8::decode_xs, avg 35µs/call # spent 3.88ms making 773 calls to Encode::Encoding::renewed, avg 5µs/call
3322500026.7ms $i++;
3332500035.8ms chomp $line;
33425000108ms2500050.4s $self->_learn_one($line);
# spent 50.4s making 25000 calls to Hailo::_learn_one, avg 2.02ms/call
33525000108ms25000864ms $progress->up;
# spent 864ms making 25000 calls to Term::Sk::up, avg 35µs/call
33612µs }
# spent 2µs making 1 call to Encode::utf8::encode_xs
337
338148µs480µs $progress->close;
# spent 46µs making 1 call to Term::Sk::close # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 5µs making 1 call to Encode::utf8::encode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
339
340157µs349µs my $elapsed = tv_interval($start_time);
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 20µs making 1 call to Time::HiRes::tv_interval # spent 3µs making 1 call to Encode::Encoding::renewed
341132µs317µs say sprintf "Trained from %d lines in %.2f seconds; %.2f lines/s", $i, $elapsed, ($i / $elapsed);
# spent 14µs making 1 call to Hailo::Command::CORE:say # spent 3µs making 2 calls to Encode::utf8::encode_xs, avg 2µs/call
342
343166µs228µs return;
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
34415µs}
# spent 5µs making 1 call to Encode::utf8::encode_xs
345
346152µs228µs# --i--do-not-exist
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
34712µssub _getopt_spec_exception { goto &_getopt_full_usage }
# spent 2µs making 1 call to Encode::utf8::encode_xs
348
349152µs228µs# --help
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
350sub _getopt_full_usage {
35112µs my ($self, $usage, $plain_str) = @_;
# spent 2µs making 1 call to Encode::utf8::encode_xs
352
353146µs230µs # If called from _getopt_spec_exception we get "Unknown option: foo"
# spent 27µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
35412µs my $warning = ref $usage eq 'ARRAY' ? $usage->[0] : undef;
# spent 2µs making 1 call to Encode::utf8::encode_xs
355
356150µs228µs my ($use, $options) = do {
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
357 # $plain_str under _getopt_spec_exception
35812µs my $out = $plain_str // $usage->text;
# spent 2µs making 1 call to Encode::utf8::encode_xs
359
3601108µs228µs # The default getopt order sucks, use reverse sort order
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
361 chomp(my @out = split /^/, $out);
362 my $opt = join "\n", sort { $b cmp $a } @out[1 .. $#out];
363 ($out[0], $opt);
364 };
365 my $synopsis = do {
366 require Pod::Usage;
367 my $out;
36812µs open my $fh, '>', \$out;
# spent 2µs making 1 call to Encode::utf8::encode_xs
369
370266µs588µs
# spent 35µs (12+22) within Hailo::Command::BEGIN@370 which was called: # once (12µs+22µs) by hailo::BEGIN@8 at line 370
no warnings 'once';
# spent 35µs making 1 call to Hailo::Command::BEGIN@370 # spent 25µs making 1 call to Encode::utf8::decode_xs # spent 22µs making 1 call to warnings::unimport # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
371
372159µs228µs my $hailo = File::Spec->catfile($Hailo::Command::HERE_MOMMY, 'hailo');
# spent 25µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
373 # Try not to fail on Win32 or other odd systems which might have hailo.pl not hailo
3742211µs11.39ms
# spent 1.39ms (866µs+526µs) within Hailo::Command::BEGIN@374 which was called: # once (866µs+526µs) by hailo::BEGIN@8 at line 374
$hailo = ((glob("$hailo*"))[0]) unless -f $hailo;
# spent 1.39ms making 1 call to Hailo::Command::BEGIN@374
375 Pod::Usage::pod2usage(
376 -input => $hailo,
377 -sections => 'SYNOPSIS',
378 -output => $fh,
379 -exitval => 'noexit',
380 );
38113µs close $fh;
# spent 3µs making 1 call to Encode::utf8::encode_xs
382
383162µs235µs $out =~ s/\n+$//s;
# spent 31µs making 1 call to Encode::utf8::decode_xs # spent 4µs making 1 call to Encode::Encoding::renewed
38412µs $out =~ s/^Usage:/examples:/;
# spent 2µs making 1 call to Encode::utf8::encode_xs
385
386141µs230µs $out;
# spent 26µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
38712µs };
# spent 2µs making 1 call to Encode::utf8::encode_xs
388
389143µs234µs # Unknown option provided
# spent 31µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
39012µs print $warning if $warning;
# spent 2µs making 1 call to Encode::utf8::encode_xs
391
392143µs227µs print <<"USAGE";
# spent 24µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
393$use
394$options
395\n\tNote: All input/output and files are assumed to be UTF-8 encoded.
39612µsUSAGE
# spent 2µs making 1 call to Encode::utf8::encode_xs
397
398156µs227µs # Hack: We can't get at our object from here so we have to inspect
# spent 24µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
399 # @ARGV directly.
40013µs say "\n", $synopsis if "@ARGV" ~~ /--examples/;
# spent 3µs making 1 call to Encode::utf8::encode_xs
401
402150µs225µs exit 1;
# spent 22µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
40312µs}
# spent 2µs making 1 call to Encode::utf8::encode_xs
404
405189µs5150µs__PACKAGE__->meta->make_immutable;
# spent 111µs making 1 call to Mouse::Meta::Class::make_immutable # spent 21µs making 1 call to Encode::utf8::decode_xs # spent 14µs making 1 call to Hailo::Command::meta # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
406
407128µs350µs=head1 NAME
# spent 33µs making 1 call to Encode::utf8::decode_xs # spent 14µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
408
409125µs325µsHailo::Command - Class for the L<hailo> command-line interface to L<Hailo>
# spent 20µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
410
411129µs324µs=head1 DESCRIPTION
# spent 18µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
412
413126µs222µsThis is an internal class L<hailo> uses for its command-line
# spent 19µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
41412µsinterface. See L<Hailo> for the public interface.
# spent 2µs making 1 call to Encode::utf8::encode_xs
415
416122µs321µs=head1 PRIVATE METHODS
# spent 16µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
417
418123µs321µs=head2 C<run>
# spent 16µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
419
420124µs227µsRun Hailo in accordance with the the attributes that were passed to
# spent 20µs making 1 call to Encode::utf8::decode_xs # spent 6µs making 1 call to Encode::Encoding::renewed
421it, this method is called by the L<hailo> command-line utility and the
42212µsHailo test suite, its behavior is subject to change.
# spent 2µs making 1 call to Encode::utf8::encode_xs
423
424119µs318µs=head1 AUTHOR
# spent 13µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
425
426119µs318µsE<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
# spent 13µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
427
428118µs317µs=head1 LICENSE AND COPYRIGHT
# spent 12µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
429
430118µs316µsCopyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
# spent 12µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed # spent 2µs making 1 call to Encode::utf8::encode_xs
431
432121µs213µsThis program is free software, you can redistribute it and/or modify
# spent 10µs making 1 call to Encode::utf8::decode_xs # spent 2µs making 1 call to Encode::Encoding::renewed
43312µsit under the same terms as Perl itself.
# spent 2µs making 1 call to Encode::utf8::encode_xs
434
435166µs33.85ms=cut
# spent 3.84ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] # spent 9µs making 1 call to Encode::utf8::decode_xs # spent 3µs making 1 call to Encode::Encoding::renewed
 
# spent 93.5ms (66.8+26.7) within Hailo::Command::CORE:readline which was called 25001 times, avg 4µs/call: # 25001 times (66.8ms+26.7ms) by Hailo::Command::train_progress at line 331, avg 4µs/call
sub Hailo::Command::CORE:readline; # opcode
# spent 14µs (12+2) within Hailo::Command::CORE:say which was called: # once (12µs+2µs) by Hailo::Command::train_progress at line 341
sub Hailo::Command::CORE:say; # opcode
# spent 6.25ms within Hailo::Command::CORE:subst which was called 1426 times, avg 4µs/call: # 1426 times (6.25ms+0s) by Hailo::Command::__ANON__[lib/Hailo/Command.pm:325] at line 322, avg 4µs/call
sub Hailo::Command::CORE:subst; # opcode
# spent 4.77ms within Hailo::Command::CORE:substcont which was called 2796 times, avg 2µs/call: # 2796 times (4.77ms+0s) by Hailo::Command::__ANON__[lib/Hailo/Command.pm:325] at line 322, avg 2µs/call
sub Hailo::Command::CORE:substcont; # opcode
# spent 2µs within Hailo::Command::_go_learn which was called: # once (2µs+0s) by Hailo::Command::run at line 261
sub Hailo::Command::_go_learn; # xsub
# spent 2µs within Hailo::Command::_go_learn_reply which was called: # once (2µs+0s) by Hailo::Command::run at line 263
sub Hailo::Command::_go_learn_reply; # xsub
# spent 2µs within Hailo::Command::_go_progress which was called: # once (2µs+0s) by Hailo::Command::__ANON__[lib/Hailo/Command.pm:298] at line 293
sub Hailo::Command::_go_progress; # xsub
# spent 1µs within Hailo::Command::_go_random_reply which was called: # once (1µs+0s) by Hailo::Command::run at line 268
sub Hailo::Command::_go_random_reply; # xsub
# spent 2µs within Hailo::Command::_go_reply which was called: # once (2µs+0s) by Hailo::Command::run at line 268
sub Hailo::Command::_go_reply; # xsub
# spent 2µs within Hailo::Command::_go_stats which was called: # once (2µs+0s) by Hailo::Command::run at line 277
sub Hailo::Command::_go_stats; # xsub
# spent 4µs within Hailo::Command::_go_train which was called 3 times, avg 1µs/call: # 2 times (3µs+0s) by Hailo::Command::run at line 260, avg 1µs/call # once (2µs+0s) by Hailo::Command::run at line 249
sub Hailo::Command::_go_train; # xsub
# spent 2µs within Hailo::Command::_go_version which was called: # once (2µs+0s) by Hailo::Command::run at line 239
sub Hailo::Command::_go_version; # xsub
# spent 12µs (11+1) within Hailo::Command::brain which was called 3 times, avg 4µs/call: # 2 times (3µs+0s) by Hailo::__ANON__[lib/Hailo.pm:170] at line 140 of lib/Hailo.pm, avg 2µs/call # once (8µs+1µs) by Hailo::Command::__ANON__[lib/Hailo/Command.pm:154] at line 153
sub Hailo::Command::brain; # xsub
# spent 2µs within Hailo::Command::engine_class which was called: # once (2µs+0s) by Hailo::__ANON__[lib/Hailo.pm:170] at line 140 of lib/Hailo.pm
sub Hailo::Command::engine_class; # xsub
# spent 3µs within Hailo::Command::order which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by Hailo::__ANON__[lib/Hailo.pm:170] at line 140 of lib/Hailo.pm, avg 2µs/call
sub Hailo::Command::order; # xsub
# spent 2µs within Hailo::Command::save_on_exit which was called: # once (2µs+0s) by Hailo::DEMOLISH at line 334 of lib/Hailo.pm
sub Hailo::Command::save_on_exit; # xsub
# spent 1µs within Hailo::Command::storage_class which was called: # once (1µs+0s) by Hailo::__ANON__[lib/Hailo.pm:170] at line 140 of lib/Hailo.pm
sub Hailo::Command::storage_class; # xsub
# spent 3µs within Hailo::Command::tokenizer_class which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by Hailo::__ANON__[lib/Hailo.pm:170] at line 140 of lib/Hailo.pm, avg 2µs/call
sub Hailo::Command::tokenizer_class; # xsub