← Index
NYTProf Performance Profile   « block view • line view • sub view »
For reply.pl
  Run on Thu Oct 21 22:40:13 2010
Reported on Thu Oct 21 22:44:44 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/Hailo/Role/Tokenizer.pm
StatementsExecuted 19 statements in 398µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11147µs134µsHailo::Role::Tokenizer::::BEGIN@9Hailo::Role::Tokenizer::BEGIN@9
11124µs26µsHailo::Role::Tokenizer::::BUILDHailo::Role::Tokenizer::BUILD
11120µs20µsHailo::Role::Tokenizer::::BEGIN@2Hailo::Role::Tokenizer::BEGIN@2
11114µs87µsHailo::Role::Tokenizer::::BEGIN@9.14Hailo::Role::Tokenizer::BEGIN@9.14
11112µs448µsHailo::Role::Tokenizer::::BEGIN@10Hailo::Role::Tokenizer::BEGIN@10
11112µs1.40msHailo::Role::Tokenizer::::BEGIN@11Hailo::Role::Tokenizer::BEGIN@11
1115µs5µsHailo::Role::Tokenizer::::__ANON__[:21]Hailo::Role::Tokenizer::__ANON__[:21]
1115µs5µsHailo::Role::Tokenizer::::BEGIN@5Hailo::Role::Tokenizer::BEGIN@5
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Hailo::Role::Tokenizer;
2
# spent 20µs within Hailo::Role::Tokenizer::BEGIN@2 which was called: # once (20µs+0s) by Mouse::Util::_try_load_one_class at line 4
BEGIN {
317µs $Hailo::Role::Tokenizer::AUTHORITY = 'cpan:AVAR';
4124µs120µs}
# spent 20µs making 1 call to Hailo::Role::Tokenizer::BEGIN@2
5
# spent 5µs within Hailo::Role::Tokenizer::BEGIN@5 which was called: # once (5µs+0s) by Mouse::Util::_try_load_one_class at line 7
BEGIN {
616µs $Hailo::Role::Tokenizer::VERSION = '0.57';
7118µs15µs}
# spent 5µs making 1 call to Hailo::Role::Tokenizer::BEGIN@5
8
9478µs3294µs
# spent 134µs (47+87) within Hailo::Role::Tokenizer::BEGIN@9 which was called: # once (47µs+87µs) by Mouse::Util::_try_load_one_class at line 9 # spent 87µs (14+73) within Hailo::Role::Tokenizer::BEGIN@9.14 which was called: # once (14µs+73µs) by Hailo::Role::Tokenizer::BEGIN@9 at line 9
use 5.010;
# spent 134µs making 1 call to Hailo::Role::Tokenizer::BEGIN@9 # spent 87µs making 1 call to Hailo::Role::Tokenizer::BEGIN@9.14 # spent 74µs making 1 call to feature::import
10232µs2884µs
# spent 448µs (12+436) within Hailo::Role::Tokenizer::BEGIN@10 which was called: # once (12µs+436µs) by Mouse::Util::_try_load_one_class at line 10
use Any::Moose '::Role';
# spent 448µs making 1 call to Hailo::Role::Tokenizer::BEGIN@10 # spent 436µs making 1 call to Any::Moose::import
112145µs22.78ms
# spent 1.40ms (12µs+1.38) within Hailo::Role::Tokenizer::BEGIN@11 which was called: # once (12µs+1.38ms) by Mouse::Util::_try_load_one_class at line 11
use namespace::clean -except => 'meta';
# spent 1.40ms making 1 call to Hailo::Role::Tokenizer::BEGIN@11 # spent 1.38ms making 1 call to namespace::clean::import
12
13has spacing => (
14 isa => 'HashRef[Int]',
15 is => 'rw',
16
# spent 5µs within Hailo::Role::Tokenizer::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/Hailo/Role/Tokenizer.pm:21] which was called: # once (5µs+0s) by Mouse::Object::new at line 207 of Hailo.pm
default => sub { {
1718µs normal => 0,
18 prefix => 1,
19 postfix => 2,
20 infix => 3,
21 } },
2217µs159µs);
# spent 59µs making 1 call to Mouse::Role::has
23
24
# spent 26µs (24+2) within Hailo::Role::Tokenizer::BUILD which was called: # once (24µs+2µs) by Mouse::Object::new at line 207 of Hailo.pm
sub BUILD {
2512µs my ($self) = @_;
26
27 # This performance hack is here because calling
28 # $self->spacing->{...} was significant part Tokenizer execution
29 # time (~20s / ~1200s) since we're doing one method call and a
30 # hash dereference
31
3219µs12µs my $spacing = $self->spacing;
# spent 2µs making 1 call to Hailo::Tokenizer::Words::spacing
33112µs while (my ($k, $v) = each %$spacing) {
34 $self->{"_spacing_$k"} = $v;
35 }
36
3715µs return;
38}
39
4014µs166µsrequires 'make_tokens';
# spent 66µs making 1 call to Mouse::Role::requires
4114µs153µsrequires 'make_output';
# spent 53µs making 1 call to Mouse::Role::requires
42
43114µs1;
44
45=encoding utf8
46
47=head1 NAME
48
49Hailo::Role::Tokenizer - A role representing a L<Hailo|Hailo> tokenizer
50
51=head1 METHODS
52
53=head2 C<new>
54
55This is the constructor. It takes no arguments.
56
57=head2 C<make_tokens>
58
59Takes a line of input and returns an array reference of tokens. A token is
60an array reference containing two elements: a I<spacing attribute> and the
61I<token text>. The spacing attribute is an integer which will be stored along
62with the token text in the database. The following values are currently being
63used:
64
65=over
66
67=item C<0> - normal token
68
69=item C<1> - prefix token (no whitespace follows it)
70
71=item C<2> - postfix token (no whitespace precedes it)
72
73=item C<3> - infix token (no whitespace follows or precedes it)
74
75=back
76
77=head2 C<make_output>
78
79Takes an array reference of tokens and returns a line of output. A token an
80array reference as described in L<C<make_tokens>|/make_tokens>. The tokens
81will be joined together into a sentence according to the whitespace
82attributes associated with the tokens.
83
84=head1 AUTHORS
85
86Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com
87
88E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
89
90=head1 LICENSE AND COPYRIGHT
91
92Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson and
93E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
94
95This program is free software, you can redistribute it and/or modify
96it under the same terms as Perl itself.
97
98125µs14.57ms=cut