Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/Hailo/Role/Tokenizer.pm |
Statements | Executed 19 statements in 398µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 47µs | 134µs | BEGIN@9 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 24µs | 26µs | BUILD | Hailo::Role::Tokenizer::
1 | 1 | 1 | 20µs | 20µs | BEGIN@2 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 14µs | 87µs | BEGIN@9.14 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 12µs | 448µs | BEGIN@10 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 12µs | 1.40ms | BEGIN@11 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 5µs | 5µs | __ANON__[:21] | Hailo::Role::Tokenizer::
1 | 1 | 1 | 5µs | 5µs | BEGIN@5 | Hailo::Role::Tokenizer::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package 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 | ||||
3 | 1 | 7µs | $Hailo::Role::Tokenizer::AUTHORITY = 'cpan:AVAR'; | ||
4 | 1 | 24µs | 1 | 20µ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 | ||||
6 | 1 | 6µs | $Hailo::Role::Tokenizer::VERSION = '0.57'; | ||
7 | 1 | 18µs | 1 | 5µs | } # spent 5µs making 1 call to Hailo::Role::Tokenizer::BEGIN@5 |
8 | |||||
9 | 4 | 78µs | 3 | 294µs | 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 |
10 | 2 | 32µs | 2 | 884µ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 # spent 448µs making 1 call to Hailo::Role::Tokenizer::BEGIN@10
# spent 436µs making 1 call to Any::Moose::import |
11 | 2 | 145µs | 2 | 2.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 # spent 1.40ms making 1 call to Hailo::Role::Tokenizer::BEGIN@11
# spent 1.38ms making 1 call to namespace::clean::import |
12 | |||||
13 | has 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 | ||||
17 | 1 | 8µs | normal => 0, | ||
18 | prefix => 1, | ||||
19 | postfix => 2, | ||||
20 | infix => 3, | ||||
21 | } }, | ||||
22 | 1 | 7µs | 1 | 59µ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 | ||||
25 | 4 | 28µ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 | |||||
32 | 1 | 2µs | my $spacing = $self->spacing; # spent 2µs making 1 call to Hailo::Tokenizer::Words::spacing | ||
33 | while (my ($k, $v) = each %$spacing) { | ||||
34 | $self->{"_spacing_$k"} = $v; | ||||
35 | } | ||||
36 | |||||
37 | return; | ||||
38 | } | ||||
39 | |||||
40 | 1 | 4µs | 1 | 66µs | requires 'make_tokens'; # spent 66µs making 1 call to Mouse::Role::requires |
41 | 1 | 4µs | 1 | 53µs | requires 'make_output'; # spent 53µs making 1 call to Mouse::Role::requires |
42 | |||||
43 | 1 | 14µs | 1; | ||
44 | |||||
45 | =encoding utf8 | ||||
46 | |||||
47 | =head1 NAME | ||||
48 | |||||
49 | Hailo::Role::Tokenizer - A role representing a L<Hailo|Hailo> tokenizer | ||||
50 | |||||
51 | =head1 METHODS | ||||
52 | |||||
53 | =head2 C<new> | ||||
54 | |||||
55 | This is the constructor. It takes no arguments. | ||||
56 | |||||
57 | =head2 C<make_tokens> | ||||
58 | |||||
59 | Takes a line of input and returns an array reference of tokens. A token is | ||||
60 | an array reference containing two elements: a I<spacing attribute> and the | ||||
61 | I<token text>. The spacing attribute is an integer which will be stored along | ||||
62 | with the token text in the database. The following values are currently being | ||||
63 | used: | ||||
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 | |||||
79 | Takes an array reference of tokens and returns a line of output. A token an | ||||
80 | array reference as described in L<C<make_tokens>|/make_tokens>. The tokens | ||||
81 | will be joined together into a sentence according to the whitespace | ||||
82 | attributes associated with the tokens. | ||||
83 | |||||
84 | =head1 AUTHORS | ||||
85 | |||||
86 | Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com | ||||
87 | |||||
88 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||||
89 | |||||
90 | =head1 LICENSE AND COPYRIGHT | ||||
91 | |||||
92 | Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson and | ||||
93 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||||
94 | |||||
95 | This program is free software, you can redistribute it and/or modify | ||||
96 | it under the same terms as Perl itself. | ||||
97 | |||||
98 | 1 | 25µs | 1 | 4.57ms | =cut # spent 4.57ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |