Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Model.pm |
Statements | Executed 4075 statements in 31.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
331 | 1 | 1 | 19.8ms | 1.78s | get_hardware_overview | Tapper::Model::
180 | 1 | 1 | 19.5ms | 2.77s | free_hosts_with_features | Tapper::Model::
1 | 1 | 1 | 1.70ms | 1.94ms | BEGIN@24 | Tapper::Model::
1 | 1 | 1 | 640µs | 20.5ms | BEGIN@25 | Tapper::Model::
1 | 1 | 1 | 337µs | 16.0ms | model | Tapper::Model::
1 | 1 | 1 | 256µs | 359µs | BEGIN@26 | Tapper::Model::
1 | 1 | 1 | 45µs | 100µs | BEGIN@13 | Tapper::Model::
1 | 1 | 1 | 11µs | 62µs | BEGIN@90 | Tapper::Model::
1 | 1 | 1 | 9µs | 27µs | BEGIN@10 | Tapper::Model::
1 | 1 | 1 | 9µs | 54µs | BEGIN@13.3 | Tapper::Model::
1 | 1 | 1 | 9µs | 9µs | BEGIN@2 | Tapper::Model::
1 | 1 | 1 | 9µs | 13µs | BEGIN@11 | Tapper::Model::
1 | 1 | 1 | 9µs | 27µs | BEGIN@21 | Tapper::Model::
1 | 1 | 1 | 8µs | 8µs | BEGIN@22 | Tapper::Model::
0 | 0 | 0 | 0s | 0s | get_or_create_user | Tapper::Model::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Tapper::Model; | ||||
2 | # spent 9µs within Tapper::Model::BEGIN@2 which was called:
# once (9µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 4 | ||||
3 | 1 | 5µs | $Tapper::Model::AUTHORITY = 'cpan:AMD'; | ||
4 | 1 | 24µs | 1 | 9µs | } # spent 9µs making 1 call to Tapper::Model::BEGIN@2 |
5 | { | ||||
6 | 2 | 1µs | $Tapper::Model::VERSION = '0.001'; | ||
7 | } | ||||
8 | # ABSTRACT: Tapper - Context sensitive connected DBIC schema | ||||
9 | |||||
10 | 3 | 27µs | 2 | 45µs | # spent 27µs (9+18) within Tapper::Model::BEGIN@10 which was called:
# once (9µs+18µs) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 10 # spent 27µs making 1 call to Tapper::Model::BEGIN@10
# spent 18µs making 1 call to warnings::import |
11 | 3 | 21µs | 2 | 16µs | # spent 13µs (9+4) within Tapper::Model::BEGIN@11 which was called:
# once (9µs+4µs) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 11 # spent 13µs making 1 call to Tapper::Model::BEGIN@11
# spent 4µs making 1 call to strict::import |
12 | |||||
13 | 6 | 68µs | 3 | 200µs | use 5.010; # spent 100µs making 1 call to Tapper::Model::BEGIN@13
# spent 54µs making 1 call to Tapper::Model::BEGIN@13.3
# spent 46µs making 1 call to feature::import |
14 | |||||
15 | # avoid these warnings | ||||
16 | # Subroutine initialize redefined at /2home/ss5/perl510/lib/site_perl/5.10.0/Class/C3.pm line 70. | ||||
17 | # Subroutine uninitialize redefined at /2home/ss5/perl510/lib/site_perl/5.10.0/Class/C3.pm line 88. | ||||
18 | # Subroutine reinitialize redefined at /2home/ss5/perl510/lib/site_perl/5.10.0/Class/C3.pm line 101. | ||||
19 | # by forcing correct load order. | ||||
20 | |||||
21 | 3 | 19µs | 2 | 44µs | # spent 27µs (9+18) within Tapper::Model::BEGIN@21 which was called:
# once (9µs+18µs) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 21 # spent 27µs making 1 call to Tapper::Model::BEGIN@21
# spent 18µs making 1 call to Class::C3::import |
22 | 3 | 19µs | 1 | 8µs | # spent 8µs within Tapper::Model::BEGIN@22 which was called:
# once (8µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 22 # spent 8µs making 1 call to Tapper::Model::BEGIN@22 |
23 | |||||
24 | 3 | 128µs | 2 | 1.97ms | # spent 1.94ms (1.70+242µs) within Tapper::Model::BEGIN@24 which was called:
# once (1.70ms+242µs) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 24 # spent 1.94ms making 1 call to Tapper::Model::BEGIN@24
# spent 34µs making 1 call to Exporter::import |
25 | 3 | 124µs | 1 | 20.5ms | # spent 20.5ms (640µs+19.9) within Tapper::Model::BEGIN@25 which was called:
# once (640µs+19.9ms) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 25 # spent 20.5ms making 1 call to Tapper::Model::BEGIN@25 |
26 | 3 | 396µs | 2 | 387µs | # spent 359µs (256+103) within Tapper::Model::BEGIN@26 which was called:
# once (256µs+103µs) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 26 # spent 359µs making 1 call to Tapper::Model::BEGIN@26
# spent 28µs making 1 call to parent::import |
27 | |||||
28 | 1 | 900ns | our @EXPORT_OK = qw(model get_hardware_overview); | ||
29 | |||||
30 | |||||
31 | 1 | 2µs | 1 | 204µs | memoize('model'); # spent 204µs making 1 call to Memoize::memoize |
32 | sub model | ||||
33 | # spent 16.0ms (337µs+15.7) within Tapper::Model::model which was called:
# once (337µs+15.7ms) by Memoize::_memoizer at line 245 of Memoize.pm | ||||
34 | 8 | 272µs | my ($schema_basename) = @_; | ||
35 | |||||
36 | $schema_basename ||= 'TestrunDB'; | ||||
37 | |||||
38 | my $schema_class = "Tapper::Schema::$schema_basename"; | ||||
39 | |||||
40 | # lazy load class | ||||
41 | eval "use $schema_class"; ## no critic (ProhibitStringyEval) # spent 92µs executing statements in string eval # includes 78µs spent executing 1 call to 1 sub defined therein. | ||||
42 | if ($@) { | ||||
43 | print STDERR $@; | ||||
44 | return; | ||||
45 | } | ||||
46 | 4 | 10.5ms | my $model = $schema_class->connect(Tapper::Config->subconfig->{database}{$schema_basename}{dsn}, # spent 10.5ms making 1 call to DBIx::Class::Schema::connect
# spent 10µs making 3 calls to Tapper::Config::subconfig, avg 3µs/call | ||
47 | Tapper::Config->subconfig->{database}{$schema_basename}{username}, | ||||
48 | Tapper::Config->subconfig->{database}{$schema_basename}{password}); | ||||
49 | 1 | 18µs | eval { | ||
50 | # maybe no TestrunSchedulings in DB yet | ||||
51 | 1 | 11µs | 4 | 5.10ms | $model->resultset('TestrunScheduling')->first->gen_schema_functions if $schema_basename eq 'TestrunDB'; # spent 2.96ms making 1 call to DBIx::Class::ResultSet::first
# spent 1.91ms making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::gen_schema_functions
# spent 228µs making 1 call to DBIx::Class::Schema::resultset
# spent 4µs making 1 call to DBIx::Class::Storage::DBI::Cursor::DESTROY |
52 | }; | ||||
53 | 1 | 16µs | 1 | 44µs | return $model; # spent 44µs making 1 call to DBIx::Class::Storage::DBI::Cursor::DESTROY |
54 | } | ||||
55 | |||||
56 | |||||
57 | sub get_or_create_user { | ||||
58 | my ($login) = @_; | ||||
59 | my $user_search = model('TestrunDB')->resultset('User')->search({ login => $login }); | ||||
60 | my $user_id; | ||||
61 | if (not $user_search->count) { | ||||
62 | my $user = model('TestrunDB')->resultset('User')->new({ login => $login }); | ||||
63 | $user->insert; | ||||
64 | return $user->id; | ||||
65 | } else { | ||||
66 | my $user = $user_search->first; # at least one user | ||||
67 | return $user->id; | ||||
68 | |||||
69 | } | ||||
70 | return; | ||||
71 | } | ||||
72 | |||||
73 | |||||
74 | sub free_hosts_with_features | ||||
75 | # spent 2.77s (19.5ms+2.75) within Tapper::Model::free_hosts_with_features which was called 180 times, avg 15.4ms/call:
# 180 times (19.5ms+2.75s) by Tapper::MCP::Scheduler::Controller::get_next_job at line 78 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 15.4ms/call | ||||
76 | 720 | 8.01ms | 540 | 164ms | my $hosts = model('TestrunDB')->resultset("Host")->free_hosts; # spent 112ms making 180 calls to DBIx::Class::Schema::resultset, avg 620µs/call
# spent 49.6ms making 180 calls to Tapper::Schema::TestrunDB::ResultSet::Host::free_hosts, avg 275µs/call
# spent 2.39ms making 180 calls to Memoize::__ANON__[(eval 256)[Memoize.pm:71]:1], avg 13µs/call |
77 | my @hosts_with_features; | ||||
78 | 1324 | 5.01ms | 511 | 791ms | while (my $host = $hosts->next) { # spent 791ms making 511 calls to DBIx::Class::ResultSet::next, avg 1.55ms/call |
79 | 662 | 1.78s | my $features = get_hardware_overview($host->id); # spent 1.78s making 331 calls to Tapper::Model::get_hardware_overview, avg 5.37ms/call
# spent 4.60ms making 331 calls to Tapper::Schema::TestrunDB::Result::Host::id, avg 14µs/call | ||
80 | 331 | 4.15ms | $features->{hostname} = $host->name; # spent 4.15ms making 331 calls to Tapper::Schema::TestrunDB::Result::Host::name, avg 13µs/call | ||
81 | my $queues = []; | ||||
82 | # $queues = [ map {$_->queue->id } $host->queuehosts->all ]; | ||||
83 | push @hosts_with_features, {host => $host, features => $features, queues => $queues}; | ||||
84 | } | ||||
85 | return \@hosts_with_features; | ||||
86 | } | ||||
87 | |||||
- - | |||||
90 | 3 | 98µs | 2 | 112µs | # spent 62µs (11+50) within Tapper::Model::BEGIN@90 which was called:
# once (11µs+50µs) by Tapper::MCP::Scheduler::Controller::BEGIN@8 at line 90 # spent 62µs making 1 call to Tapper::Model::BEGIN@90
# spent 50µs making 1 call to Exporter::import |
91 | |||||
92 | sub get_hardware_overview | ||||
93 | # spent 1.78s (19.8ms+1.76) within Tapper::Model::get_hardware_overview which was called 331 times, avg 5.37ms/call:
# 331 times (19.8ms+1.76s) by Tapper::Model::free_hosts_with_features at line 79, avg 5.37ms/call | ||||
94 | 1986 | 17.0ms | my ($host_id) = @_; | ||
95 | |||||
96 | 993 | 961ms | my $host = model('TestrunDB')->resultset('Host')->find($host_id); # spent 857ms making 331 calls to DBIx::Class::ResultSet::find, avg 2.59ms/call
# spent 101ms making 331 calls to DBIx::Class::Schema::resultset, avg 305µs/call
# spent 2.39ms making 331 calls to Memoize::__ANON__[(eval 256)[Memoize.pm:71]:1], avg 7µs/call | ||
97 | return qq(Host with id '$host_id' not found) unless $host; | ||||
98 | |||||
99 | my %all_features; | ||||
100 | |||||
101 | 331 | 790ms | foreach my $feature ($host->features) { # spent 790ms making 331 calls to Tapper::Schema::TestrunDB::Result::Host::features, avg 2.39ms/call | ||
102 | $all_features{$feature->entry} = $feature->value; | ||||
103 | } | ||||
104 | return \%all_features; | ||||
105 | |||||
106 | } | ||||
107 | |||||
108 | |||||
109 | 1 | 5µs | 1; # End of Tapper::Model | ||
110 | |||||
111 | __END__ |