← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:15 2013

Filename/Users/dde/HackaMol_devel/HackaMol/lib/roles/PhysVecRole.pm
StatementsExecuted 200018 statements in 387ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
20000011142ms142msPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:20]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:20]
11122µs1.85msPhysVecRole::::BEGIN@3PhysVecRole::BEGIN@3
1117µs35µsPhysVecRole::::BEGIN@4PhysVecRole::BEGIN@4
0000s0sPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:114]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:114]
0000s0sPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:128]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:128]
0000s0sPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:157]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:157]
0000s0sPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:192]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:192]
0000s0sPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:39]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:39]
0000s0sPhysVecRole::::__ANON__[lib/roles/PhysVecRole.pm:46]PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:46]
0000s0sPhysVecRole::::_build_chargePhysVecRole::_build_charge
0000s0sPhysVecRole::::_build_coordPhysVecRole::_build_coord
0000s0sPhysVecRole::::_build_delta_charges_coderefPhysVecRole::_build_delta_charges_coderef
0000s0sPhysVecRole::::_build_delta_coords_coderefPhysVecRole::_build_delta_coords_coderef
0000s0sPhysVecRole::::_build_delta_forces_coderefPhysVecRole::_build_delta_forces_coderef
0000s0sPhysVecRole::::_build_distance_coderefPhysVecRole::_build_distance_coderef
0000s0sPhysVecRole::::_build_forcesPhysVecRole::_build_forces
0000s0sPhysVecRole::::delta_chargesPhysVecRole::delta_charges
0000s0sPhysVecRole::::delta_coordsPhysVecRole::delta_coords
0000s0sPhysVecRole::::delta_forcesPhysVecRole::delta_forces
0000s0sPhysVecRole::::distancePhysVecRole::distance
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PhysVecRole;
2# ABSTRACT: Provides the core of HackaMol Atom and Molecule classes.
3229µs23.68ms
# spent 1.85ms (22µs+1.83) within PhysVecRole::BEGIN@3 which was called: # once (22µs+1.83ms) by Module::Runtime::require_module at line 3
use Moose::Role;
# spent 1.85ms making 1 call to PhysVecRole::BEGIN@3 # spent 1.83ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:519]
42838µs263µs
# spent 35µs (7+28) within PhysVecRole::BEGIN@4 which was called: # once (7µs+28µs) by Module::Runtime::require_module at line 4
use Carp;
# spent 35µs making 1 call to PhysVecRole::BEGIN@4 # spent 28µs making 1 call to Exporter::import
5
612µs13.77mshas 'name' , is => 'rw', isa => 'Str' ;
# spent 3.77ms making 1 call to Moose::Role::has
7
811µs178µshas 'mass' , is => 'rw', isa => 'Num' , lazy => 1, default => 0;
# spent 78µs making 1 call to Moose::Role::has
9
101900ns176µshas 't' , is => 'rw', isa => 'Int|ScalarRef' , default => 0;
# spent 76µs making 1 call to Moose::Role::has
11
121900ns170µshas 'is_fixed' , is => 'rw', isa => 'Bool', lazy => 1, default => 0;
# spent 70µs making 1 call to Moose::Role::has
13
14
151800nsmy @t_dep = qw(coords forces charges);
16
17has "_t$_" => (
18 traits => [ 'Array' ],
19 isa => 'ArrayRef',
20200000386ms
# spent 142ms within PhysVecRole::__ANON__[lib/roles/PhysVecRole.pm:20] which was called 200000 times, avg 711ns/call: # 200000 times (142ms+0s) by Atom::push_coords at line 10 of (eval 74)[Eval/Closure.pm:135], avg 711ns/call
default => sub { [] },
21 handles =>
22 {
23 "push_$_" => 'push' ,
24 "get_$_" => 'get' ,
25 "set_$_" => 'set' ,
26 "all_$_" => 'elements',
27 "clear_$_" => 'clear' ,
28 "count_$_" => 'count' ,
29 },
30 lazy => 1,
31117µs3221µs ) for @t_dep;
# spent 221µs making 3 calls to Moose::Role::has, avg 74µs/call
32
33
341700ns168µshas 'units' , is => 'rw', isa => 'Str' ; #flag for future use [SI]
# spent 68µs making 1 call to Moose::Role::has
35
36has 'origin' => (
37 is => 'rw',
38 isa => 'ArrayRef',
39 default => sub{[0,0,0]},
4012µs167µs lazy => 1,
# spent 67µs making 1 call to Moose::Role::has
41 );
42
43has 'xyzfree' => (
44 is => 'rw',
45 isa => 'ArrayRef[Int]',
46 default => sub{[1,1,1]},
4712µs170µs lazy => 1,
# spent 70µs making 1 call to Moose::Role::has
48 );
49
50has $_ => (
51 is => 'rw',
52 isa => 'Num',
53 builder => "_build_$_",
54 lazy => 1,
55 predicate => "has_$_",
5612µs177µs ) foreach qw(charge);
# spent 77µs making 1 call to Moose::Role::has
57
58has $_ => (
59 is => 'rw',
60 isa => 'ArrayRef',
61 builder => "_build_$_",
62 lazy => 1,
63 predicate => "has_$_",
6414µs2146µs ) foreach qw(coord force);
# spent 146µs making 2 calls to Moose::Role::has, avg 73µs/call
65
66sub _build_charge {
67 my $self = shift;
68 if ($self->count_charges){
69 return ( $self->get_charges($self->t) );
70 }
71 else {
72 return (0);
73 }
74}
75
76sub _build_coord {
77 my $self = shift;
78 if ($self->count_coords){
79 return ( $self->get_coords($self->t) );
80 }
81 else {
82 return ([0,0,0]);
83 }
84}
85
86sub _build_forces {
87 my $self = shift;
88 if ($self->count_forces){
89 return ( $self->get_forces($self->t) );
90 }
91 else {
92 return ([0,0,0]);
93 }
94}
95
96
97has "$_\_coderef" => (
98 is => 'rw',
99 isa => 'CodeRef',
100 builder => "_build_$_\_coderef",
101 lazy => 1,
10215µs3212µs ) foreach qw (delta_charges delta_coords delta_forces);
# spent 212µs making 3 calls to Moose::Role::has, avg 71µs/call
103
- -
106sub _build_delta_charges_coderef {
107 my $self = shift;
108 my $sub = sub{
109 my $self = shift;
110 my $ti = shift;
111 my $tf = shift;
112 my $dq = $self->get_charges($tf) - $self->get_charges($ti);
113 return ($dq);
114 };
115 return ($sub);
116}
117
118
119sub _build_delta_coords_coderef {
120 my $self = shift;
121 my $sub = sub{
122 my $self = shift;
123 my $ti = shift;
124 my $tf = shift;
125 my $vi = $self->get_coords($ti);
126 my $vf = $self->get_coords($tf);
127 return ([map{$vf->[$_]- $vi->[$_]} 0 .. 2]);
128 };
129 return ($sub);
130}
131
132sub delta_charges {
133 my $self = shift;
134 croak "delta_charges> pass initial and final time" unless (@_ == 2);
135 my $ti = shift;
136 my $tf = shift;
137 &{$self->delta_charges_coderef}($self,$ti,$tf);
138}
139
140sub delta_coords {
141 my $self = shift;
142 croak "delta_coords> pass initial and final time" unless (@_ == 2);
143 my $ti = shift;
144 my $tf = shift;
145 &{$self->delta_coords_coderef}($self,$ti,$tf);
146}
147
148sub _build_delta_forces_coderef {
149 my $self = shift;
150 my $sub = sub{
151 my $self = shift;
152 my $ti = shift;
153 my $tf = shift;
154 my $vi = $self->get_forces($ti);
155 my $vf = $self->get_forces($tf);
156 return ([map{$vf->[$_]- $vi->[$_]} 0 .. 2]);
157 };
158 return ($sub);
159}
160
161sub delta_forces {
162 my $self = shift;
163 croak "delta_forces> pass initial and final time" unless (@_ == 2);
164 my $ti = shift;
165 my $tf = shift;
166 &{$self->delta_forces_coderef}($self,$ti,$tf);
167}
168
169
1701800ns168µshas 'distance_coderef' => (
# spent 68µs making 1 call to Moose::Role::has
171 is => 'rw',
172 isa => 'CodeRef',
173 builder => '_build_distance_coderef',
174 lazy => 1,
175 );
176
177sub _build_distance_coderef {
178 my $self = shift;
179 my $sub = sub{
180 my $obj1 = shift;
181 my $obj2 = shift;
182 my $tobj1 = $obj1->t;
183 my $tobj2 = $obj2->t;
184 if ($tobj1 != $tobj2){
185 carp "you are comparing the distance between objects with different times";
186 }
187 my $vec1 = $obj1->get_coords($tobj1);
188 my $vec2 = $obj2->get_coords($tobj2);
189 my $dist = 0;
190 $dist += ($vec1->[$_]-$vec2->[$_])**2 foreach 0 .. 2;
191 return (sqrt($dist));
192 };
193 return ($sub);
194}
195
196sub distance {
197 my $self = shift;
198 my $obj2 = shift or croak "need to pass another obj that does PhysVecRole" ;
199 my $dist = &{$self->distance_coderef}($self,$obj2);
200 return ($dist);
201}
202
203130µs1;
204
205__END__