Filename | /mnt/stuff/src/my-cpan/hailo/lib/Hailo/Role/Tokenizer.pm |
Statements | Executed 17 statements in 321µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 56µs | 142µs | BEGIN@3 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 23µs | 25µs | BUILD | Hailo::Role::Tokenizer::
1 | 1 | 1 | 16µs | 86µs | BEGIN@3.19 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 12µs | 463µs | BEGIN@4 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 12µs | 1.38ms | BEGIN@5 | Hailo::Role::Tokenizer::
1 | 1 | 1 | 5µs | 5µs | __ANON__[lib/Hailo/Role/Tokenizer.pm:15] | Hailo::Role::Tokenizer::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Hailo::Role::Tokenizer; | ||||
2 | |||||
3 | 4 | 76µs | 3 | 298µs | use 5.010; # spent 142µs making 1 call to Hailo::Role::Tokenizer::BEGIN@3
# spent 86µs making 1 call to Hailo::Role::Tokenizer::BEGIN@3.19
# spent 70µs making 1 call to feature::import |
4 | 2 | 32µs | 2 | 913µs | # spent 463µs (12+451) within Hailo::Role::Tokenizer::BEGIN@4 which was called:
# once (12µs+451µs) by Mouse::Util::_try_load_one_class at line 4 # spent 463µs making 1 call to Hailo::Role::Tokenizer::BEGIN@4
# spent 451µs making 1 call to Any::Moose::import |
5 | 2 | 153µs | 2 | 2.75ms | # spent 1.38ms (12µs+1.37) within Hailo::Role::Tokenizer::BEGIN@5 which was called:
# once (12µs+1.37ms) by Mouse::Util::_try_load_one_class at line 5 # spent 1.38ms making 1 call to Hailo::Role::Tokenizer::BEGIN@5
# spent 1.37ms making 1 call to namespace::clean::import |
6 | |||||
7 | has spacing => ( | ||||
8 | isa => 'HashRef[Int]', | ||||
9 | is => 'rw', | ||||
10 | # spent 5µs within Hailo::Role::Tokenizer::__ANON__[lib/Hailo/Role/Tokenizer.pm:15] which was called:
# once (5µs+0s) by Mouse::Object::new at line 201 of lib/Hailo.pm | ||||
11 | 1 | 8µs | normal => 0, | ||
12 | prefix => 1, | ||||
13 | postfix => 2, | ||||
14 | infix => 3, | ||||
15 | } }, | ||||
16 | 1 | 5µs | 1 | 40µs | ); # spent 40µs making 1 call to Mouse::Role::has |
17 | |||||
18 | # spent 25µs (23+2) within Hailo::Role::Tokenizer::BUILD which was called:
# once (23µs+2µs) by Mouse::Object::new at line 201 of lib/Hailo.pm | ||||
19 | 4 | 27µs | my ($self) = @_; | ||
20 | |||||
21 | # This performance hack is here because calling | ||||
22 | # $self->spacing->{...} was significant part Tokenizer execution | ||||
23 | # time (~20s / ~1200s) since we're doing one method call and a | ||||
24 | # hash dereference | ||||
25 | |||||
26 | 1 | 2µs | my $spacing = $self->spacing; # spent 2µs making 1 call to Hailo::Tokenizer::Words::spacing | ||
27 | while (my ($k, $v) = each %$spacing) { | ||||
28 | $self->{"_spacing_$k"} = $v; | ||||
29 | } | ||||
30 | |||||
31 | return; | ||||
32 | } | ||||
33 | |||||
34 | 1 | 3µs | 1 | 64µs | requires 'make_tokens'; # spent 64µs making 1 call to Mouse::Role::requires |
35 | 1 | 3µs | 1 | 50µs | requires 'make_output'; # spent 50µs making 1 call to Mouse::Role::requires |
36 | |||||
37 | 1 | 6µs | 1; | ||
38 | |||||
39 | =encoding utf8 | ||||
40 | |||||
41 | =head1 NAME | ||||
42 | |||||
43 | Hailo::Role::Tokenizer - A role representing a L<Hailo|Hailo> tokenizer | ||||
44 | |||||
45 | =head1 METHODS | ||||
46 | |||||
47 | =head2 C<new> | ||||
48 | |||||
49 | This is the constructor. It takes no arguments. | ||||
50 | |||||
51 | =head2 C<make_tokens> | ||||
52 | |||||
53 | Takes a line of input and returns an array reference of tokens. A token is | ||||
54 | an array reference containing two elements: a I<spacing attribute> and the | ||||
55 | I<token text>. The spacing attribute is an integer which will be stored along | ||||
56 | with the token text in the database. The following values are currently being | ||||
57 | used: | ||||
58 | |||||
59 | =over | ||||
60 | |||||
61 | =item C<0> - normal token | ||||
62 | |||||
63 | =item C<1> - prefix token (no whitespace follows it) | ||||
64 | |||||
65 | =item C<2> - postfix token (no whitespace precedes it) | ||||
66 | |||||
67 | =item C<3> - infix token (no whitespace follows or precedes it) | ||||
68 | |||||
69 | =back | ||||
70 | |||||
71 | =head2 C<make_output> | ||||
72 | |||||
73 | Takes an array reference of tokens and returns a line of output. A token an | ||||
74 | array reference as described in L<C<make_tokens>|/make_tokens>. The tokens | ||||
75 | will be joined together into a sentence according to the whitespace | ||||
76 | attributes associated with the tokens. | ||||
77 | |||||
78 | =head1 AUTHORS | ||||
79 | |||||
80 | Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com | ||||
81 | |||||
82 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||||
83 | |||||
84 | =head1 LICENSE AND COPYRIGHT | ||||
85 | |||||
86 | Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson and | ||||
87 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||||
88 | |||||
89 | This program is free software, you can redistribute it and/or modify | ||||
90 | it under the same terms as Perl itself. | ||||
91 | |||||
92 | 1 | 8µs | 1 | 4.31ms | =cut # spent 4.31ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |