← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:18 2013

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm
StatementsExecuted 16048 statements in 1.78s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
492811108ms108msOCBNET::Spritesets::Canvas::::addOCBNET::Spritesets::Canvas::add
121122.4ms10.1sOCBNET::Spritesets::Canvas::::drawOCBNET::Spritesets::Canvas::draw
121111.9ms165msOCBNET::Spritesets::Canvas::::newOCBNET::Spritesets::Canvas::new
11110.4ms58.1msOCBNET::Spritesets::Canvas::::BEGIN@18OCBNET::Spritesets::Canvas::BEGIN@18
1114.80ms5.44msOCBNET::Spritesets::Canvas::::BEGIN@21OCBNET::Spritesets::Canvas::BEGIN@21
1114.70ms10.5msOCBNET::Spritesets::Canvas::::BEGIN@19OCBNET::Spritesets::Canvas::BEGIN@19
1114.68ms5.30msOCBNET::Spritesets::Canvas::::BEGIN@20OCBNET::Spritesets::Canvas::BEGIN@20
60533.25ms3.25msOCBNET::Spritesets::Canvas::::areasOCBNET::Spritesets::Canvas::areas
12112.67ms2.67msOCBNET::Spritesets::Canvas::::spritesOCBNET::Spritesets::Canvas::sprites
111142µs242µsOCBNET::Spritesets::Canvas::::BEGIN@13OCBNET::Spritesets::Canvas::BEGIN@13
11159µs6.89msOCBNET::Spritesets::Canvas::::BEGIN@25OCBNET::Spritesets::Canvas::BEGIN@25
11158µs94µsOCBNET::Spritesets::Canvas::::BEGIN@14OCBNET::Spritesets::Canvas::BEGIN@14
0000s0sOCBNET::Spritesets::Canvas::::debugOCBNET::Spritesets::Canvas::debug
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1###################################################################################################
2# Copyright 2013 by Marcel Greter
3# This file is part of Webmerge (GPL3)
4####################################################################################################
5# this is the main canvas or root block to be drawn
6# it contains four stacked frames on each side, four
7# more edge areas, four corner areas and one in the
8# center where the sprites are packed into minimal space
9####################################################################################################
10package OCBNET::Spritesets::Canvas;
11####################################################################################################
12
132178µs2342µs
# spent 242µs (142+100) within OCBNET::Spritesets::Canvas::BEGIN@13 which was called: # once (142µs+100µs) by OCBNET::Spritesets::BEGIN@25 at line 13
use strict;
# spent 242µs making 1 call to OCBNET::Spritesets::Canvas::BEGIN@13 # spent 100µs making 1 call to strict::import
142148µs2129µs
# spent 94µs (58+35) within OCBNET::Spritesets::Canvas::BEGIN@14 which was called: # once (58µs+35µs) by OCBNET::Spritesets::BEGIN@25 at line 14
use warnings;
# spent 94µs making 1 call to OCBNET::Spritesets::Canvas::BEGIN@14 # spent 35µs making 1 call to warnings::import
15
16####################################################################################################
17
182648µs258.4ms
# spent 58.1ms (10.4+47.7) within OCBNET::Spritesets::Canvas::BEGIN@18 which was called: # once (10.4ms+47.7ms) by OCBNET::Spritesets::BEGIN@25 at line 18
use OCBNET::Spritesets::Canvas::Layout;
# spent 58.1ms making 1 call to OCBNET::Spritesets::Canvas::BEGIN@18 # spent 248µs making 1 call to Exporter::import
192612µs210.7ms
# spent 10.5ms (4.70+5.81) within OCBNET::Spritesets::Canvas::BEGIN@19 which was called: # once (4.70ms+5.81ms) by OCBNET::Spritesets::BEGIN@25 at line 19
use OCBNET::Spritesets::Canvas::Optimize;
# spent 10.5ms making 1 call to OCBNET::Spritesets::Canvas::BEGIN@19 # spent 226µs making 1 call to Exporter::import
202614µs25.49ms
# spent 5.30ms (4.68+616µs) within OCBNET::Spritesets::Canvas::BEGIN@20 which was called: # once (4.68ms+616µs) by OCBNET::Spritesets::BEGIN@25 at line 20
use OCBNET::Spritesets::Canvas::Repeater;
# spent 5.30ms making 1 call to OCBNET::Spritesets::Canvas::BEGIN@20 # spent 189µs making 1 call to Exporter::import
212762µs25.64ms
# spent 5.44ms (4.80+649µs) within OCBNET::Spritesets::Canvas::BEGIN@21 which was called: # once (4.80ms+649µs) by OCBNET::Spritesets::BEGIN@25 at line 21
use OCBNET::Spritesets::Canvas::Distribute;
# spent 5.44ms making 1 call to OCBNET::Spritesets::Canvas::BEGIN@21 # spent 198µs making 1 call to Exporter::import
22
23####################################################################################################
24
2524.69ms213.7ms
# spent 6.89ms (59µs+6.83) within OCBNET::Spritesets::Canvas::BEGIN@25 which was called: # once (59µs+6.83ms) by OCBNET::Spritesets::BEGIN@25 at line 25
use base 'OCBNET::Spritesets::Container';
# spent 6.89ms making 1 call to OCBNET::Spritesets::Canvas::BEGIN@25 # spent 6.83ms making 1 call to base::import
26
27####################################################################################################
28
29# all areas where we can
30# have a child container
31121µsmy @areas =
32(
33 'corner-lt',
34 'stack-t',
35 'edge-t',
36 'corner-rt',
37 'stack-l',
38 'middle',
39 'stack-r',
40 'edge-l',
41 'edge-r',
42 'corner-lb',
43 'stack-b',
44 'edge-b',
45 'corner-rb'
46);
47
48####################################################################################################
49
50# create a new object
51# ******************************************************************************
52sub new
53
# spent 165ms (11.9+153) within OCBNET::Spritesets::Canvas::new which was called 12 times, avg 13.8ms/call: # 12 times (11.9ms+153ms) by OCBNET::Spritesets::CSS::Parser::read at line 153 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 13.8ms/call
{
54
55 # get package name, parent and options
561267µs my ($pckg, $parent, $options) = @_;
57
58 # get object by calling super class
5912542µs12122ms my $self = $pckg->SUPER::new($parent);
# spent 122ms making 12 calls to OCBNET::Spritesets::Container::new, avg 10.2ms/call
60
61 # this is the base container which will be rendered and
62 # saved to a file, so we always have 0/0 as coordinates
6324334µs24287µs $self->left = 0; $self->top = 0;
# spent 159µs making 12 calls to OCBNET::Spritesets::Block::left, avg 13µs/call # spent 128µs making 12 calls to OCBNET::Spritesets::Block::top, avg 11µs/call
64
65 # initialize the width and the height
6624364µs24322µs $self->width = 0; $self->height = 0;
# spent 190µs making 12 calls to OCBNET::Spritesets::Block::width, avg 16µs/call # spent 132µs making 12 calls to OCBNET::Spritesets::Block::height, avg 11µs/call
67
68 # array with all sprites
691268µs $self->{'sprites'} = [];
70
71 # debug mode variable
721239µs $self->{'debug'} = $options->{'debug'};
73
74 # assign or init the options hash
751228µs $self->{'options'} = $options || {};
76
77 # create and initialize the fitter area (if used or not)
7812332µs121.64ms $self->{'middle'} = new OCBNET::Spritesets::Fit($self);
# spent 1.64ms making 12 calls to OCBNET::Spritesets::Container::new, avg 137µs/call
79
80 # create and initialize the sub areas (if used or not)
8112301µs122.44ms $self->{'edge-t'} = new OCBNET::Spritesets::Edge($self, 0, 0);
# spent 2.44ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 203µs/call
8212234µs122.15ms $self->{'edge-r'} = new OCBNET::Spritesets::Edge($self, 1, 1);
# spent 2.15ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 179µs/call
8312241µs122.10ms $self->{'edge-b'} = new OCBNET::Spritesets::Edge($self, 0, 1);
# spent 2.10ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 175µs/call
8412225µs122.08ms $self->{'edge-l'} = new OCBNET::Spritesets::Edge($self, 1, 0);
# spent 2.08ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 173µs/call
85
86 # create and initialize the sub areas (if used or not)
8712244µs122.13ms $self->{'stack-t'} = new OCBNET::Spritesets::Stack($self, 0, 0);
# spent 2.13ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 177µs/call
8812235µs122.09ms $self->{'stack-r'} = new OCBNET::Spritesets::Stack($self, 1, 1);
# spent 2.09ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 174µs/call
8912240µs122.15ms $self->{'stack-b'} = new OCBNET::Spritesets::Stack($self, 0, 1);
# spent 2.15ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 179µs/call
9012239µs122.19ms $self->{'stack-l'} = new OCBNET::Spritesets::Stack($self, 1, 0);
# spent 2.19ms making 12 calls to OCBNET::Spritesets::Stack::new, avg 183µs/call
91
92 # create and initialize the sub areas (if used or not)
9312278µs122.28ms $self->{'corner-lt'} = new OCBNET::Spritesets::Corner($self, 0, 0);
# spent 2.28ms making 12 calls to OCBNET::Spritesets::Corner::new, avg 190µs/call
9412226µs122.16ms $self->{'corner-rt'} = new OCBNET::Spritesets::Corner($self, 1, 0);
# spent 2.16ms making 12 calls to OCBNET::Spritesets::Corner::new, avg 180µs/call
9512228µs122.14ms $self->{'corner-lb'} = new OCBNET::Spritesets::Corner($self, 0, 1);
# spent 2.14ms making 12 calls to OCBNET::Spritesets::Corner::new, avg 178µs/call
9612232µs122.15ms $self->{'corner-rb'} = new OCBNET::Spritesets::Corner($self, 1, 1);
# spent 2.15ms making 12 calls to OCBNET::Spritesets::Corner::new, avg 179µs/call
97
98 # register the name of each area (debug only)
9912946µs $self->{$_}->{'name'} = $_ foreach @areas;
100
101 # if in debug mode we assign background colors
102 # this way you can see what got distributed where
1031234µs if ($self->{'debug'})
104 {
105 $self->{'middle'}->{'bg'} = 'xc:rgba(0, 255, 0, 0.25)';
106 $self->{'edge-t'}->{'bg'} = 'xc:rgba(150, 30, 0, 0.25)';
107 $self->{'edge-r'}->{'bg'} = 'xc:rgba(150, 80, 0, 0.25)';
108 $self->{'edge-b'}->{'bg'} = 'xc:rgba(150, 130, 0, 0.25)';
109 $self->{'edge-l'}->{'bg'} = 'xc:rgba(150, 180, 0, 0.25)';
110 $self->{'stack-t'}->{'bg'} = 'xc:rgba(30, 0, 150, 0.25)';
111 $self->{'stack-r'}->{'bg'} = 'xc:rgba(80, 0, 150, 0.25)';
112 $self->{'stack-b'}->{'bg'} = 'xc:rgba(130, 0, 150, 0.25)';
113 $self->{'stack-l'}->{'bg'} = 'xc:rgba(180, 0, 150, 0.25)';
114 $self->{'corner-lt'}->{'bg'} = 'xc:rgba(0, 150, 30, 0.25)';
115 $self->{'corner-rt'}->{'bg'} = 'xc:rgba(0, 150, 80, 0.25)';
116 $self->{'corner-lb'}->{'bg'} = 'xc:rgba(0, 150, 130, 0.25)';
117 $self->{'corner-rb'}->{'bg'} = 'xc:rgba(0, 150, 180, 0.25)';
118 }
119
120 # add the widgets to parent
12112208µs12472µs foreach my $area ($self->areas)
# spent 472µs making 12 calls to OCBNET::Spritesets::Canvas::areas, avg 39µs/call
1221563.68ms1562.59ms { $self->SUPER::add($area); }
# spent 2.59ms making 156 calls to OCBNET::Spritesets::Container::add, avg 17µs/call
123
124 # reset the children array
1251277µs $self->{'children'} = [];
126
127 # return object
12812285µs return $self;
129
130}
131# EO new
132
133####################################################################################################
134
135603.61ms
# spent 3.25ms within OCBNET::Spritesets::Canvas::areas which was called 60 times, avg 54µs/call: # 12 times (909µs+0s) by OCBNET::Spritesets::Canvas::draw at line 177, avg 76µs/call # 12 times (663µs+0s) by OCBNET::Spritesets::Canvas::Layout::layout at line 108 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 55µs/call # 12 times (622µs+0s) by OCBNET::Spritesets::Canvas::Repeater::repeater at line 35 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Repeater.pm, avg 52µs/call # 12 times (583µs+0s) by OCBNET::Spritesets::Canvas::Layout::layout at line 379 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 49µs/call # 12 times (472µs+0s) by OCBNET::Spritesets::Canvas::new at line 121, avg 39µs/call
sub areas { return map { $_[0]->{$_} } @areas; }
136
137####################################################################################################
138# add a sprite to the canvas - put it into the
139# correct area according to its configuration
140####################################################################################################
141
142# ******************************************************************************
143sub add
144
# spent 108ms within OCBNET::Spritesets::Canvas::add which was called 4928 times, avg 22µs/call: # 4928 times (108ms+0s) by OCBNET::Spritesets::CSS::Parser::load at line 286 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 22µs/call
{
145
146 # get method arguments
147492819.5ms my ($self, $sprite) = @_;
148
149 # push the sprite on to the array
150492830.4ms push (@{$self->{'sprites'}}, $sprite);
151
152 # success
1534928129ms return 1;
154
155}
156# EO add
157
158####################################################################################################
159
160
161####################################################################################################
162
163sub draw
164
# spent 10.1s (22.4ms+10.1) within OCBNET::Spritesets::Canvas::draw which was called 12 times, avg 842ms/call: # 12 times (22.4ms+10.1s) by OCBNET::Spritesets::CSS::Parser::write at line 410 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 842ms/call
{
165
166 # get our object
1671252µs my ($self) = @_;
168
169 # initialize empty image
170121.73ms121.41ms $self->{'image'}->Set(matte => 'True');
# spent 1.41ms making 12 calls to Graphics::Magick::Set, avg 118µs/call
17112579µs12357µs $self->{'image'}->Set(magick => 'png');
# spent 357µs making 12 calls to Graphics::Magick::Set, avg 30µs/call
17212806µs241.38ms $self->{'image'}->Set(size => $self->size);
# spent 933µs making 12 calls to OCBNET::Spritesets::Block::size, avg 78µs/call # spent 445µs making 12 calls to Graphics::Magick::Set, avg 37µs/call
17312457ms12457ms $self->{'image'}->ReadImage($self->{'bg'});
# spent 457ms making 12 calls to Graphics::Magick::ReadImage, avg 38.1ms/call
17412677ms12676ms $self->{'image'}->Quantize(colorspace=>'RGB');
# spent 676ms making 12 calls to Graphics::Magick::Quantize, avg 56.3ms/call
175
176 # process all possible areas
17712591µs12909µs foreach my $area ($self->areas)
# spent 909µs making 12 calls to OCBNET::Spritesets::Canvas::areas, avg 76µs/call
178 {
179
180 # ignore area if it's empty
1811562.95ms1563.36ms next if $area->empty;
# spent 3.36ms making 156 calls to OCBNET::Spritesets::Container::empty, avg 22µs/call
182
183 # get our own dimensions
1841081.81ms1081.56ms my $width = $self->width;
# spent 1.56ms making 108 calls to OCBNET::Spritesets::Block::width, avg 14µs/call
1851081.48ms1081.29ms my $height = $self->height;
# spent 1.29ms making 108 calls to OCBNET::Spritesets::Block::height, avg 12µs/call
186
187 ##########################################################
188 # draw main areas on the canvas
189 ##########################################################
190
191 # draw background on canvas
192108396µs if ($area->{'img-bg'})
193 {
194 $self->{'image'}->Composite(
195 compose => 'Over',
196 x => $area->left,
197 y => $area->top,
198 image => $area->{'img-bg'}
199 );
200 }
201
202 # draw foreground on canvas
203108430ms4322.28s $self->{'image'}->Composite(
# spent 1.86s making 108 calls to OCBNET::Spritesets::Container::draw, avg 17.2ms/call # spent 422ms making 108 calls to Graphics::Magick::Composite, avg 3.91ms/call # spent 1.32ms making 108 calls to OCBNET::Spritesets::Block::left, avg 12µs/call # spent 1.21ms making 108 calls to OCBNET::Spritesets::Block::top, avg 11µs/call
204 compose => 'Over',
205 x => $area->left,
206 y => $area->top,
207 image => $area->draw
208 );
209
210 }
211 # EO each area
212
213 # call repeater
21412176µs126.66s $self->repeater;
# spent 6.66s making 12 calls to OCBNET::Spritesets::Canvas::Repeater::repeater, avg 555ms/call
215
216 # return the image instance
21712277µs return $self->{'image'};
218
219}
220# EO sub draw
221
222####################################################################################################
223
224122.84ms
# spent 2.67ms within OCBNET::Spritesets::Canvas::sprites which was called 12 times, avg 222µs/call: # 12 times (2.67ms+0s) by OCBNET::Spritesets::Canvas::Layout::layout at line 118 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 222µs/call
sub sprites { @{$_[0]->{'sprites'}} }
225
226####################################################################################################
227
228sub debug
229{
230 my ($self) = @_;
231 print "#" x 78, "\n";
232 printf "DEBUG SPRITESET <%s> (%sx%s)\n",
233 $self->{'id'}, $self->width, $self->height;
234 print "#" x 78, "\n";
235 foreach my $area ($self->areas)
236 {
237 print "AREA: ", $area->{'name'}, " ", $area->debug, "\n";
238 foreach my $sprite ($area->children)
239 {
240 print " SPRITE: ", $sprite->debug, "\n";
241 }
242 }
243 print "#" x 75, "\n";
244
245}
246
247####################################################################################################
248####################################################################################################
249119µs1;