Profile of MooseX/Traits/Util.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:43 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/MooseX/Traits/Util.pm
Statements | Executed 41 statements in 620µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 77µs | 641µs | MooseX::Traits::Util::::transform_traitMooseX::Traits::Util::transform_trait
1 | 1 | 1 | 76µs | 10.9ms | MooseX::Traits::Util::::new_class_with_traitsMooseX::Traits::Util::new_class_with_traits
1 | 1 | 1 | 61µs | 1.21ms | MooseX::Traits::Util::::resolve_traitsMooseX::Traits::Util::resolve_traits
3 | 3 | 1 | 52µs | 1.45ms | MooseX::Traits::Util::::check_classMooseX::Traits::Util::check_class
1 | 1 | 1 | 17µs | 22µs | MooseX::Traits::Util::::BEGIN@2MooseX::Traits::Util::BEGIN@2
1 | 1 | 1 | 11µs | 267µs | MooseX::Traits::Util::::BEGIN@5MooseX::Traits::Util::BEGIN@5
1 | 1 | 1 | 9µs | 23µs | MooseX::Traits::Util::::BEGIN@3MooseX::Traits::Util::BEGIN@3
1 | 1 | 1 | 8µs | 46µs | MooseX::Traits::Util::::BEGIN@9MooseX::Traits::Util::BEGIN@9
1 | 1 | 1 | 5µs | 5µs | MooseX::Traits::Util::::CORE:matchMooseX::Traits::Util::CORE:match (opcode)

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package MooseX::Traits::Util;
2 | 3 | 24µs | 2 | 26µs | # spent 22µs (17+5) within MooseX::Traits::Util::BEGIN@2 which was called: # once (17µs+5µs) by MooseX::Traits::BEGIN@4 at line 2 use strict; # spent 22µs making 1 call to MooseX::Traits::Util::BEGIN@2 # spent 5µs making 1 call to strict::import
3 | 3 | 36µs | 2 | 38µs | # spent 23µs (9+15) within MooseX::Traits::Util::BEGIN@3 which was called: # once (9µs+15µs) by MooseX::Traits::BEGIN@4 at line 3 use warnings; # spent 23µs making 1 call to MooseX::Traits::Util::BEGIN@3 # spent 15µs making 1 call to warnings::import
4 |  |  |  |  |
5 | 1 | 9µs | 1 | 257µs | # spent 267µs (11+257) within MooseX::Traits::Util::BEGIN@5 which was called: # once (11µs+257µs) by MooseX::Traits::BEGIN@4 at line 7 use Sub::Exporter -setup => { # spent 257µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
6 |  |  |  |  | exports => ['new_class_with_traits'],
7 | 2 | 19µs | 1 | 267µs | }; # spent 267µs making 1 call to MooseX::Traits::Util::BEGIN@5
8 |  |  |  |  |
9 | 3 | 310µs | 2 | 84µs | # spent 46µs (8+38) within MooseX::Traits::Util::BEGIN@9 which was called: # once (8µs+38µs) by MooseX::Traits::BEGIN@4 at line 9 use Carp qw(confess); # spent 46µs making 1 call to MooseX::Traits::Util::BEGIN@9 # spent 38µs making 1 call to Exporter::import
10 |  |  |  |  |
11 |  |  |  |  | # note: "$class" throughout is "class name" or "instance of class
12 |  |  |  |  | # name"
13 |  |  |  |  |
14 |  |  |  |  | # spent 1.45ms (52µs+1.40) within MooseX::Traits::Util::check_class which was called 3 times, avg 483µs/call: # once (34µs+646µs) by MooseX::Traits::Util::new_class_with_traits at line 63 # once (9µs+380µs) by MooseX::Traits::Util::resolve_traits at line 43 # once (9µs+371µs) by MooseX::Traits::Util::transform_trait at line 25 sub check_class {
15 | 3 | 5µs |  |  | my $class = shift;
16 |  |  |  |  |
17 | 3 | 53µs | 3 | 1.40ms | confess "We can't interact with traits for a class ($class) ". # spent 1.40ms making 3 calls to Moose::Object::does, avg 466µs/call
18 |  |  |  |  | "that does not do MooseX::Traits" unless $class->does('MooseX::Traits');
19 |  |  |  |  | }
20 |  |  |  |  |
21 |  |  |  |  | # spent 641µs (77+564) within MooseX::Traits::Util::transform_trait which was called: # once (77µs+564µs) by MooseX::Traits::Util::resolve_traits at line 48 sub transform_trait {
22 | 1 | 2µs |  |  | my ($class, $name) = @_;
23 | 1 | 18µs | 1 | 5µs | return $1 if $name =~ /^[+](.+)$/; # spent 5µs making 1 call to MooseX::Traits::Util::CORE:match
24 |  |  |  |  |
25 | 1 | 5µs | 1 | 380µs | check_class($class); # spent 380µs making 1 call to MooseX::Traits::Util::check_class
26 |  |  |  |  |
27 | 1 | 22µs | 2 | 173µs | my $namespace = $class->meta->find_attribute_by_name('_trait_namespace'); # spent 134µs making 1 call to Class::MOP::Class::find_attribute_by_name # spent 39µs making 1 call to Tapper::MCP::Scheduler::Algorithm::meta
28 | 1 | 800ns |  |  | my $base;
29 | 1 | 7µs | 1 | 6µs | if($namespace->has_default){ # spent 6µs making 1 call to Class::MOP::Mixin::AttributeCore::has_default
30 |  |  |  |  | $base = $namespace->default;
31 |  |  |  |  | if(ref $base eq 'CODE'){
32 |  |  |  |  | $base = $base->();
33 |  |  |  |  | }
34 |  |  |  |  | }
35 |  |  |  |  |
36 | 1 | 11µs |  |  | return $name unless $base;
37 |  |  |  |  | return join '::', $base, $name;
38 |  |  |  |  | }
39 |  |  |  |  |
40 |  |  |  |  | # spent 1.21ms (61µs+1.15) within MooseX::Traits::Util::resolve_traits which was called: # once (61µs+1.15ms) by MooseX::Traits::Util::new_class_with_traits at line 66 sub resolve_traits {
41 | 1 | 4µs |  |  | my ($class, @traits) = @_;
42 |  |  |  |  |
43 | 1 | 5µs | 1 | 389µs | check_class($class); # spent 389µs making 1 call to MooseX::Traits::Util::check_class
44 |  |  |  |  |
45 | 1 | 2µs |  |  | return map {
46 | 1 | 13µs |  |  | my $orig = $_;
47 | 1 | 2µs |  |  | if(!ref $orig){
48 | 1 | 5µs | 1 | 641µs | my $transformed = transform_trait($class, $orig); # spent 641µs making 1 call to MooseX::Traits::Util::transform_trait
49 | 1 | 4µs | 1 | 8µs | Class::MOP::load_class($transformed); # spent 8µs making 1 call to Class::MOP::load_class
50 | 1 | 2µs |  |  | $transformed;
51 |  |  |  |  | }
52 |  |  |  |  | else {
53 |  |  |  |  | $orig;
54 |  |  |  |  | }
55 |  |  |  |  | } @traits;
56 |  |  |  |  | }
57 |  |  |  |  |
58 | 1 | 300ns |  |  | my $anon_serial = 0;
59 |  |  |  |  |
60 |  |  |  |  | # spent 10.9ms (76µs+10.9) within MooseX::Traits::Util::new_class_with_traits which was called: # once (76µs+10.9ms) by MooseX::Traits::with_traits at line 24 of MooseX/Traits.pm sub new_class_with_traits {
61 | 1 | 3µs |  |  | my ($class, @traits) = @_;
62 |  |  |  |  |
63 | 1 | 8µs | 1 | 680µs | check_class($class); # spent 680µs making 1 call to MooseX::Traits::Util::check_class
64 |  |  |  |  |
65 | 1 | 800ns |  |  | my $meta;
66 | 1 | 8µs | 1 | 1.21ms | @traits = resolve_traits($class, @traits); # spent 1.21ms making 1 call to MooseX::Traits::Util::resolve_traits
67 | 1 | 33µs | 4 | 8.97ms | if (@traits) { # spent 8.91ms making 1 call to Moose::Meta::Class::create # spent 60µs making 2 calls to Tapper::MCP::Scheduler::Algorithm::meta, avg 30µs/call # spent 2µs making 1 call to Class::MOP::Package::name
68 |  |  |  |  | $meta = $class->meta->create(
69 |  |  |  |  | join(q{::} => 'MooseX::Traits::__ANON__::SERIAL', ++$anon_serial),
70 |  |  |  |  | superclasses => [ $class->meta->name ],
71 |  |  |  |  | roles => \@traits,
72 |  |  |  |  | cache => 1,
73 |  |  |  |  | );
74 |  |  |  |  | }
75 |  |  |  |  |
76 |  |  |  |  | # if no traits were given just return the class meta
77 | 1 | 6µs |  |  | return $meta ? $meta : $class->meta;
78 |  |  |  |  | }
79 |  |  |  |  |
80 | 1 | 3µs |  |  | 1;
|  |  |  |  | # spent 5µs within MooseX::Traits::Util::CORE:match which was called: # once (5µs+0s) by MooseX::Traits::Util::transform_trait at line 23 sub MooseX::Traits::Util::CORE:match; # opcode