← 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:16 2010

Filename/mnt/stuff/src/my-cpan/hailo/lib/Hailo/Role/Tokenizer.pm
StatementsExecuted 17 statements in 321µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11156µs142µsHailo::Role::Tokenizer::::BEGIN@3Hailo::Role::Tokenizer::BEGIN@3
11123µs25µsHailo::Role::Tokenizer::::BUILDHailo::Role::Tokenizer::BUILD
11116µs86µsHailo::Role::Tokenizer::::BEGIN@3.19Hailo::Role::Tokenizer::BEGIN@3.19
11112µs463µsHailo::Role::Tokenizer::::BEGIN@4Hailo::Role::Tokenizer::BEGIN@4
11112µs1.38msHailo::Role::Tokenizer::::BEGIN@5Hailo::Role::Tokenizer::BEGIN@5
1115µs5µsHailo::Role::Tokenizer::::__ANON__[lib/Hailo/Role/Tokenizer.pm:15]Hailo::Role::Tokenizer::__ANON__[lib/Hailo/Role/Tokenizer.pm:15]
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
3476µs3298µs
# spent 86µs (16+70) within Hailo::Role::Tokenizer::BEGIN@3.19 which was called: # once (16µs+70µs) by Hailo::Role::Tokenizer::BEGIN@3 at line 3 # spent 142µs (56+86) within Hailo::Role::Tokenizer::BEGIN@3 which was called: # once (56µs+86µs) by Mouse::Util::_try_load_one_class at line 3
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
4232µs2913µ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
use Any::Moose '::Role';
# spent 463µs making 1 call to Hailo::Role::Tokenizer::BEGIN@4 # spent 451µs making 1 call to Any::Moose::import
52153µs22.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
use namespace::clean -except => 'meta';
# spent 1.38ms making 1 call to Hailo::Role::Tokenizer::BEGIN@5 # spent 1.37ms making 1 call to namespace::clean::import
6
7has 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
default => sub { {
1118µs normal => 0,
12 prefix => 1,
13 postfix => 2,
14 infix => 3,
15 } },
1615µs140µ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
sub BUILD {
1912µ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
2618µs12µs my $spacing = $self->spacing;
# spent 2µs making 1 call to Hailo::Tokenizer::Words::spacing
27112µs while (my ($k, $v) = each %$spacing) {
28 $self->{"_spacing_$k"} = $v;
29 }
30
3115µs return;
32}
33
3413µs164µsrequires 'make_tokens';
# spent 64µs making 1 call to Mouse::Role::requires
3513µs150µsrequires 'make_output';
# spent 50µs making 1 call to Mouse::Role::requires
36
3716µs1;
38
39=encoding utf8
40
41=head1 NAME
42
43Hailo::Role::Tokenizer - A role representing a L<Hailo|Hailo> tokenizer
44
45=head1 METHODS
46
47=head2 C<new>
48
49This is the constructor. It takes no arguments.
50
51=head2 C<make_tokens>
52
53Takes a line of input and returns an array reference of tokens. A token is
54an array reference containing two elements: a I<spacing attribute> and the
55I<token text>. The spacing attribute is an integer which will be stored along
56with the token text in the database. The following values are currently being
57used:
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
73Takes an array reference of tokens and returns a line of output. A token an
74array reference as described in L<C<make_tokens>|/make_tokens>. The tokens
75will be joined together into a sentence according to the whitespace
76attributes associated with the tokens.
77
78=head1 AUTHORS
79
80Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com
81
82E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
83
84=head1 LICENSE AND COPYRIGHT
85
86Copyright 2010 Hinrik E<Ouml>rn SigurE<eth>sson and
87E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
88
89This program is free software, you can redistribute it and/or modify
90it under the same terms as Perl itself.
91
9218µs14.31ms=cut