← 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/Repeater.pm
StatementsExecuted 92610 statements in 3.85s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
12111.67s6.66sOCBNET::Spritesets::Canvas::Repeater::::repeaterOCBNET::Spritesets::Canvas::Repeater::repeater
11186µs185µsOCBNET::Spritesets::Canvas::Repeater::::BEGIN@10OCBNET::Spritesets::Canvas::Repeater::BEGIN@10
11169µs69µsOCBNET::Spritesets::Canvas::Repeater::::BEGIN@19.4OCBNET::Spritesets::Canvas::Repeater::BEGIN@19.4
11154µs86µsOCBNET::Spritesets::Canvas::Repeater::::BEGIN@11OCBNET::Spritesets::Canvas::Repeater::BEGIN@11
11140µs40µsOCBNET::Spritesets::Canvas::Repeater::::BEGIN@19OCBNET::Spritesets::Canvas::Repeater::BEGIN@19
11126µs26µsOCBNET::Spritesets::Canvas::Repeater::::BEGIN@22OCBNET::Spritesets::Canvas::Repeater::BEGIN@22
11121µs21µsOCBNET::Spritesets::Canvas::Repeater::::BEGIN@16OCBNET::Spritesets::Canvas::Repeater::BEGIN@16
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# static helper functions for canvas
6####################################################################################################
7package OCBNET::Spritesets::Canvas::Repeater;
8####################################################################################################
9
102174µs2283µs
# spent 185µs (86+98) within OCBNET::Spritesets::Canvas::Repeater::BEGIN@10 which was called: # once (86µs+98µs) by OCBNET::Spritesets::Canvas::BEGIN@20 at line 10
use strict;
# spent 185µs making 1 call to OCBNET::Spritesets::Canvas::Repeater::BEGIN@10 # spent 98µs making 1 call to strict::import
112189µs2118µs
# spent 86µs (54+32) within OCBNET::Spritesets::Canvas::Repeater::BEGIN@11 which was called: # once (54µs+32µs) by OCBNET::Spritesets::Canvas::BEGIN@20 at line 11
use warnings;
# spent 86µs making 1 call to OCBNET::Spritesets::Canvas::Repeater::BEGIN@11 # spent 32µs making 1 call to warnings::import
12
13###################################################################################################
14
15# define our version string
161156µs121µs
# spent 21µs within OCBNET::Spritesets::Canvas::Repeater::BEGIN@16 which was called: # once (21µs+0s) by OCBNET::Spritesets::Canvas::BEGIN@20 at line 16
BEGIN { $OCBNET::Spritesets::Canvas::Repeater = "0.70"; }
# spent 21µs making 1 call to OCBNET::Spritesets::Canvas::Repeater::BEGIN@16
17
18# load exporter and inherit from it
193393µs2109µs
# spent 40µs within OCBNET::Spritesets::Canvas::Repeater::BEGIN@19 which was called: # once (40µs+0s) by OCBNET::Spritesets::Canvas::BEGIN@20 at line 19 # spent 69µs within OCBNET::Spritesets::Canvas::Repeater::BEGIN@19.4 which was called: # once (69µs+0s) by OCBNET::Spritesets::Canvas::BEGIN@20 at line 19
BEGIN { use Exporter qw(); our @ISA = qw(Exporter); }
# spent 69µs making 1 call to OCBNET::Spritesets::Canvas::Repeater::BEGIN@19.4 # spent 40µs making 1 call to OCBNET::Spritesets::Canvas::Repeater::BEGIN@19
20
21# define our functions to be exported
2213.52ms126µs
# spent 26µs within OCBNET::Spritesets::Canvas::Repeater::BEGIN@22 which was called: # once (26µs+0s) by OCBNET::Spritesets::Canvas::BEGIN@20 at line 22
BEGIN { our @EXPORT = qw(repeater); }
# spent 26µs making 1 call to OCBNET::Spritesets::Canvas::Repeater::BEGIN@22
23
24####################################################################################################
25
26# draw repeating sprites
27# ******************************************************************************
28sub repeater
29
# spent 6.66s (1.67+4.99) within OCBNET::Spritesets::Canvas::Repeater::repeater which was called 12 times, avg 555ms/call: # 12 times (1.67s+4.99s) by OCBNET::Spritesets::Canvas::draw at line 214 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 555ms/call
{
30
31 # get our object
321261µs my ($self) = shift;
33
34 # process all possible areas
3512311µs12622µs foreach my $area ($self->areas)
# spent 622µs making 12 calls to OCBNET::Spritesets::Canvas::areas, avg 52µs/call
36 {
37
38 # ignore area if it's empty
391562.29ms1562.58ms next if $area->empty;
# spent 2.58ms making 156 calls to OCBNET::Spritesets::Container::empty, avg 17µs/call
40
41 # get our own dimensions
421081.56ms1081.34ms my $width = $self->width;
# spent 1.34ms making 108 calls to OCBNET::Spritesets::Block::width, avg 12µs/call
431081.34ms1081.24ms my $height = $self->height;
# spent 1.24ms making 108 calls to OCBNET::Spritesets::Block::height, avg 12µs/call
44
45 ##########################################################
46 # draw repeating patterns on the canvas
47 ##########################################################
48
491089.41ms2683.47ms if (
# spent 3.47ms making 268 calls to UNIVERSAL::isa, avg 13µs/call
50
51 $area->isa('OCBNET::Spritesets::Fit') ||
52 $area->isa('OCBNET::Spritesets::Edge') ||
53 $area->isa('OCBNET::Spritesets::Stack')
54 )
55 {
56
57 # paint the repeatings
58 # process all sprites on edge
59761.35ms763.08ms foreach my $sprite ($area->children)
# spent 3.08ms making 76 calls to OCBNET::Spritesets::Container::children, avg 41µs/call
60 {
61
62 # get the sprite dimensions
63471255.8ms471254.6ms my $sprite_width = $sprite->width;
# spent 54.6ms making 4712 calls to OCBNET::Spritesets::Block::width, avg 12µs/call
64471250.6ms471249.0ms my $sprite_height = $sprite->height;
# spent 49.0ms making 4712 calls to OCBNET::Spritesets::Block::height, avg 10µs/call
65
66 # get the offset on the canvas
67471253.6ms47121.98s my $offset = $sprite->offset();
# spent 1.98s making 4712 calls to OCBNET::Spritesets::Sprite::offset, avg 420µs/call
68
69 # get offset position of inner sprite image
70471266.0ms471251.2ms my $left = $offset->{'x'} + $sprite->paddingLeft;
# spent 51.2ms making 4712 calls to OCBNET::Spritesets::Block::paddingLeft, avg 11µs/call
71471259.7ms471247.4ms my $top = $offset->{'y'} + $sprite->paddingTop;
# spent 47.4ms making 4712 calls to OCBNET::Spritesets::Block::paddingTop, avg 10µs/call
72
73 # no sprite must repeat in both directions
74 # XXX - maybe move this check to a better place
75471249.6ms494453.3ms if ($sprite->isRepeatX && $sprite->isRepeatY)
# spent 50.5ms making 4712 calls to OCBNET::Spritesets::Sprite::isRepeatX, avg 11µs/call # spent 2.89ms making 232 calls to OCBNET::Spritesets::Sprite::isRepeatY, avg 12µs/call
76 { die "fatal error: cannot repeat in both directions"; }
77
78 # is repeating on x axis
794712121ms919291.8ms if ($sprite->isRepeatX)
# spent 46.1ms making 4480 calls to OCBNET::Spritesets::Sprite::isRepeatY, avg 10µs/call # spent 45.7ms making 4712 calls to OCBNET::Spritesets::Sprite::isRepeatX, avg 10µs/call
80 {
81
82 # declare boundary vars
83232576µs my ($lower_x, $upper_x);
84
85 # check if sprite is fixed
862323.61ms2323.34ms if ($sprite->isFixedX)
# spent 3.34ms making 232 calls to OCBNET::Spritesets::Sprite::isFixedX, avg 14µs/call
87 {
88 # get the lower boundary
89168604µs $lower_x = $offset->{'x'};
90 # sum up outer width and lower boundary
911682.40ms16816.1ms $upper_x = $lower_x + $sprite->outerWidth;
# spent 16.1ms making 168 calls to OCBNET::Spritesets::Block::outerWidth, avg 96µs/call
92 }
93 # sprite has flexible width
94 else
95 {
96 # go behind the left edge
9764175µs $lower_x = - $sprite_width;
98 # and draw over the right edge
9964156µs $upper_x = $width + $sprite_width;
100 }
101 # EO if isFixedX
102
103 # draw the repeating patterns on the left side of the original drawn sprite
10423225.0ms3366.91ms for (my $i = $left - $sprite_width; $i > $lower_x - $sprite_width; $i -= $sprite_width)
# spent 6.91ms making 336 calls to Graphics::Magick::DESTROY, avg 21µs/call
105 {
106
107 # optional crop offset
10834245.16ms my $crop_offset = 0;
109
110 # get original sprite image
111342410.6ms my $image = $sprite->{'image'};
112
113 # we have to crop the image as we
114 # otherwise may paint into another
115 # confined sprite on the canvas
11634243.48ms if ($i < $lower_x)
117 {
118 # calculate the crop offset
119168168µs $crop_offset = $lower_x - $i;
120 # calculate the new width after cropping
1211682.48ms1682.15ms my $crop_width = $sprite->width - $crop_offset;
# spent 2.15ms making 168 calls to OCBNET::Spritesets::Block::width, avg 13µs/call
122 # create a clone of the sprite
12316825.5ms16821.6ms $image = $image->clone;
# spent 21.6ms making 168 calls to Graphics::Magick::clone, avg 129µs/call
124 # crop the cloned image
12516827.9ms33624.0ms $image->Crop(
# spent 21.2ms making 168 calls to Graphics::Magick::Crop, avg 126µs/call # spent 2.73ms making 168 calls to OCBNET::Spritesets::Block::height, avg 16µs/call
126 width => $crop_width,
127 height => $sprite->height,
128 x => $crop_offset, y => 0
129 );
130 }
131 # EO if needs cropping
132
133 # draw image on canvas
1343424764ms3424618ms $self->{'image'}->Composite(
# spent 618ms making 3424 calls to Graphics::Magick::Composite, avg 181µs/call
135 y => $top,
136 image => $image,
137 compose => 'over',
138 x => $i + $crop_offset
139 );
140
141 }
142 # EO each repeat on the left
143
144 # draw the repeating patterns on the right side of the original drawn sprite
14523223.5ms3366.79ms for (my $i = $left + $sprite_width; $i < $upper_x; $i += $sprite_width)
# spent 6.79ms making 336 calls to Graphics::Magick::DESTROY, avg 20µs/call
146 {
147
148 # optional crop offset
14933845.62ms my $crop_offset = 0;
150
151 # get original sprite image
152338410.9ms my $image = $sprite->{'image'};
153
154 # we have to crop the image as we
155 # otherwise may paint into another
156 # confined sprite on the canvas
15733846.57ms if ($i + $sprite_width > $upper_x)
158 {
159 # calculate the crop offset
160168231µs $crop_offset = $upper_x - $i;
161 # create a clone of the sprite
16216821.3ms16817.5ms $image = $image->clone;
# spent 17.5ms making 168 calls to Graphics::Magick::clone, avg 104µs/call
163 # crop the cloned image
16416826.1ms33622.4ms $image->Crop(
# spent 19.6ms making 168 calls to Graphics::Magick::Crop, avg 117µs/call # spent 2.81ms making 168 calls to OCBNET::Spritesets::Block::height, avg 17µs/call
165 x => 0, y => 0,
166 width => $crop_offset,
167 height => $sprite->height
168 );
169 }
170
171 # draw image on canvas
1723384704ms3384605ms $self->{'image'}->Composite(
# spent 605ms making 3384 calls to Graphics::Magick::Composite, avg 179µs/call
173 y => $top, x => $i,
174 compose => 'over',
175 image => $image
176 );
177
178 }
179 # EO each repeat on the right
180
181 }
182 # is repeating on y axis
183 elsif ($sprite->isRepeatY)
184 {
185
186 # declare boundary vars
187232473µs my ($lower_y, $upper_y);
188
189 # check if sprite is fixed
1902323.49ms2323.21ms if ($sprite->isFixedY)
# spent 3.21ms making 232 calls to OCBNET::Spritesets::Sprite::isFixedY, avg 14µs/call
191 {
192 # get the lower boundary
193168615µs $lower_y = $offset->{'y'};
194 # sum up outer height and lower boundary
1951682.37ms16816.5ms $upper_y = $lower_y + $sprite->outerHeight;
# spent 16.5ms making 168 calls to OCBNET::Spritesets::Block::outerHeight, avg 98µs/call
196 }
197 # sprite has flexible height
198 else
199 {
200 # go behind the top edge
20164191µs $lower_y = - $sprite_height;
202 # and draw over the bottom edge
20364182µs $upper_y = $height + $sprite_height;
204 }
205 # EO if isFixedY
206
207 # draw the repeating patterns on the top side of the original drawn sprite
20823224.2ms3366.96ms for (my $i = $top - $sprite_height; $i > $lower_y - $sprite_height; $i -= $sprite_height)
# spent 6.96ms making 336 calls to Graphics::Magick::DESTROY, avg 21µs/call
209 {
210
211 # optional crop offset
21233525.21ms my $crop_offset = 0;
213
214 # get original sprite image
215335210.1ms my $image = $sprite->{'image'};
216
217 # we have to crop the image as we
218 # otherwise may paint into another
219 # confined sprite on the canvas
22033523.33ms if ($i < $lower_y)
221 {
222 # calculate the crop offset
223168189µs $crop_offset = $lower_y - $i;
224 # calculate the new width after cropping
2251682.67ms1682.15ms my $crop_height = $sprite->height - $crop_offset;
# spent 2.15ms making 168 calls to OCBNET::Spritesets::Block::height, avg 13µs/call
226 # create a clone of the sprite
22716823.9ms16820.0ms $image = $image->clone;
# spent 20.0ms making 168 calls to Graphics::Magick::clone, avg 119µs/call
228 # crop the cloned image
22916825.7ms33621.7ms $image->Crop(
# spent 19.1ms making 168 calls to Graphics::Magick::Crop, avg 114µs/call # spent 2.54ms making 168 calls to OCBNET::Spritesets::Block::width, avg 15µs/call
230 height => $crop_height,
231 width => $sprite->width,
232 y => $crop_offset, x => 0
233 );
234 }
235
236 # draw image on canvas
2373352736ms3352604ms $self->{'image'}->Composite(
# spent 604ms making 3352 calls to Graphics::Magick::Composite, avg 180µs/call
238 x => $left,
239 image => $image,
240 compose => 'over',
241 y => $i + $crop_offset
242 );
243
244 }
245 # EO each repeat on the top
246
247 # draw the repeating patterns on the bottom side of the original drawn sprite
24823249.0ms3366.55ms for (my $i = $top + $sprite_height; $i < $upper_y; $i += $sprite_height)
# spent 6.55ms making 336 calls to Graphics::Magick::DESTROY, avg 19µs/call
249 {
250
251 # optional crop offset
25233125.13ms my $crop_offset = 0;
253
254 # get original sprite image
255331210.3ms my $image = $sprite->{'image'};
256
257 # we have to crop the image as we
258 # otherwise may paint into another
259 # confined sprite on the canvas
26033125.96ms if ($i + $sprite_height > $upper_y)
261 {
262
263 # calculate the crop offset
264168200µs $crop_offset = $upper_y - $i;
265 # create a clone of the sprite
26616820.8ms16817.1ms $image = $image->clone;
# spent 17.1ms making 168 calls to Graphics::Magick::clone, avg 102µs/call
267 # crop the cloned image
26816824.0ms33620.4ms $image->Crop(
# spent 17.6ms making 168 calls to Graphics::Magick::Crop, avg 105µs/call # spent 2.80ms making 168 calls to OCBNET::Spritesets::Block::width, avg 17µs/call
269 x => 0, y => 0,
270 height => $crop_offset,
271 width => $sprite->width,
272 );
273 }
274
275 # draw image on canvas
2763312752ms3312587ms $self->{'image'}->Composite(
# spent 587ms making 3312 calls to Graphics::Magick::Composite, avg 177µs/call
277 x => $left, y => $i,
278 compose => 'over',
279 image => $image
280 );
281 }
282 # EO each repeat on the bottom
283
284 }
285
286 }
287 # EO each sprite
288
289 }
290 # EO if fit/edge/stack
291
292 }
293 # EO each area
294
295 # return success
29612229µs return $self;
297
298}
299# EO sub repeater
300
301####################################################################################################
302####################################################################################################
303114µs1;