← 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:19 2013

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/Spritesets/Stack.pm
StatementsExecuted 9107 statements in 157ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
9622189ms724msOCBNET::Spritesets::Stack::::layoutOCBNET::Spritesets::Stack::layout
16045216.4ms16.4msOCBNET::Spritesets::Stack::::stackVertOCBNET::Spritesets::Stack::stackVert
96814.89ms17.3msOCBNET::Spritesets::Stack::::newOCBNET::Spritesets::Stack::new
404424.21ms4.21msOCBNET::Spritesets::Stack::::alignOppOCBNET::Spritesets::Stack::alignOpp
11190µs191µsOCBNET::Spritesets::Stack::::BEGIN@11OCBNET::Spritesets::Stack::BEGIN@11
11152µs85µsOCBNET::Spritesets::Stack::::BEGIN@12OCBNET::Spritesets::Stack::BEGIN@12
11150µs454µsOCBNET::Spritesets::Stack::::BEGIN@17OCBNET::Spritesets::Stack::BEGIN@17
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 block stacks the sprites vertically
6# or horizontally together (and aligned)
7####################################################################################################
8package OCBNET::Spritesets::Stack;
9####################################################################################################
10
112148µs2293µs
# spent 191µs (90+101) within OCBNET::Spritesets::Stack::BEGIN@11 which was called: # once (90µs+101µs) by OCBNET::Spritesets::BEGIN@28 at line 11
use strict;
# spent 191µs making 1 call to OCBNET::Spritesets::Stack::BEGIN@11 # spent 101µs making 1 call to strict::import
122158µs2117µs
# spent 85µs (52+32) within OCBNET::Spritesets::Stack::BEGIN@12 which was called: # once (52µs+32µs) by OCBNET::Spritesets::BEGIN@28 at line 12
use warnings;
# spent 85µs making 1 call to OCBNET::Spritesets::Stack::BEGIN@12 # spent 32µs making 1 call to warnings::import
13
14####################################################################################################
15
16# a container is also a block
1722.38ms2859µs
# spent 454µs (50+405) within OCBNET::Spritesets::Stack::BEGIN@17 which was called: # once (50µs+405µs) by OCBNET::Spritesets::BEGIN@28 at line 17
use base 'OCBNET::Spritesets::Container';
# spent 454µs making 1 call to OCBNET::Spritesets::Stack::BEGIN@17 # spent 405µs making 1 call to base::import
18
19####################################################################################################
20
21# create a new object
22# ******************************************************************************
23sub new
24
# spent 17.3ms (4.89+12.4) within OCBNET::Spritesets::Stack::new which was called 96 times, avg 180µs/call: # 12 times (812µs+1.62ms) by OCBNET::Spritesets::Canvas::new at line 81 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 203µs/call # 12 times (596µs+1.60ms) by OCBNET::Spritesets::Canvas::new at line 90 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 183µs/call # 12 times (579µs+1.57ms) by OCBNET::Spritesets::Canvas::new at line 89 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 179µs/call # 12 times (594µs+1.55ms) by OCBNET::Spritesets::Canvas::new at line 82 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 179µs/call # 12 times (575µs+1.55ms) by OCBNET::Spritesets::Canvas::new at line 87 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 177µs/call # 12 times (579µs+1.52ms) by OCBNET::Spritesets::Canvas::new at line 83 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 175µs/call # 12 times (578µs+1.51ms) by OCBNET::Spritesets::Canvas::new at line 88 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 174µs/call # 12 times (577µs+1.50ms) by OCBNET::Spritesets::Canvas::new at line 84 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas.pm, avg 173µs/call
{
25
26 # get package name, parent and options
2796360µs my ($pckg, $parent, $stack_vert, $align_opp) = @_;
28
29 # get object by calling super class
30962.58ms9612.4ms my $self = $pckg->SUPER::new($parent);
# spent 12.4ms making 96 calls to OCBNET::Spritesets::Container::new, avg 129µs/call
31
32 # align the the oppositioning side?
3396310µs $self->{'align-opp'} = $align_opp;
34
35 # stack vertically or horizontally?
3696176µs $self->{'stack-vert'} = $stack_vert;
37
38 # return object
39961.43ms return $self;
40
41}
42
43####################################################################################################
44
45# getter methods for the specific options
46# ******************************************************************************
474046.49ms
# spent 4.21ms within OCBNET::Spritesets::Stack::alignOpp which was called 404 times, avg 10µs/call: # 128 times (1.31ms+0s) by OCBNET::Spritesets::Stack::layout at line 89, avg 10µs/call # 116 times (1.19ms+0s) by OCBNET::Spritesets::Stack::layout at line 72, avg 10µs/call # 96 times (1.06ms+0s) by OCBNET::Spritesets::Stack::layout at line 154, avg 11µs/call # 64 times (650µs+0s) by OCBNET::Spritesets::Canvas::Layout::layout at line 389 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 10µs/call
sub alignOpp { return $_[0]->{'align-opp'}; }
48160471.2ms
# spent 16.4ms within OCBNET::Spritesets::Stack::stackVert which was called 1604 times, avg 10µs/call: # 436 times (4.59ms+0s) by OCBNET::Spritesets::Stack::layout at line 119, avg 11µs/call # 436 times (4.49ms+0s) by OCBNET::Spritesets::Stack::layout at line 64, avg 10µs/call # 436 times (4.31ms+0s) by OCBNET::Spritesets::Stack::layout at line 142, avg 10µs/call # 264 times (2.71ms+0s) by OCBNET::Spritesets::Stack::layout at line 160, avg 10µs/call # 32 times (339µs+0s) by OCBNET::Spritesets::Canvas::Layout::layout at line 389 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 11µs/call
sub stackVert { return $_[0]->{'stack-vert'}; }
49
50####################################################################################################
51
52# calculate the dimensions and inner positions
53# ******************************************************************************
54sub layout
55
# spent 724ms (189+535) within OCBNET::Spritesets::Stack::layout which was called 96 times, avg 7.54ms/call: # 48 times (134ms+398ms) by OCBNET::Spritesets::Edge::layout at line 31 of webmerge/scripts/modules/OCBNET/Spritesets/Edge.pm, avg 11.1ms/call # 48 times (55.5ms+137ms) by OCBNET::Spritesets::Canvas::Layout::layout at line 108 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 4.01ms/call
{
56
57 # get our object
5896304µs my ($self) = @_;
59
60 # process all sprites in this stack
61961.58ms961.37ms foreach my $sprite ($self->children)
# spent 1.37ms making 96 calls to OCBNET::Spritesets::Container::children, avg 14µs/call
62 {
63 # top/bottom edge/stack
644366.16ms4364.49ms if ($self->stackVert)
# spent 4.49ms making 436 calls to OCBNET::Spritesets::Stack::stackVert, avg 10µs/call
65 {
66 # sprite has px position
672122.29ms2126.44ms if ($sprite->alignLeft)
# spent 6.44ms making 212 calls to OCBNET::Spritesets::Sprite::alignLeft, avg 30µs/call
68 {
69 # never needs right margin
701161.16ms1161.21ms $sprite->paddingRight = 0;
# spent 1.21ms making 116 calls to OCBNET::Spritesets::Block::paddingRight, avg 10µs/call
71 # only optimize top edge/stack
721161.30ms1161.19ms unless ($self->alignOpp)
# spent 1.19ms making 116 calls to OCBNET::Spritesets::Stack::alignOpp, avg 10µs/call
73 {
74 # keep left margin if repeating
75 # unless ($sprite->isRepeatX)
76921.00ms92948µs { $sprite->paddingLeft = 0; }
# spent 948µs making 92 calls to OCBNET::Spritesets::Block::paddingLeft, avg 10µs/call
77 }
78 }
79 }
80 # left/right edge/stack
81 else
82 {
83 # sprite has px position
842242.36ms2246.53ms if ($sprite->alignTop)
# spent 6.53ms making 224 calls to OCBNET::Spritesets::Sprite::alignTop, avg 29µs/call
85 {
86 # never needs bottom margin
871281.25ms1281.38ms $sprite->paddingBottom = 0;
# spent 1.38ms making 128 calls to OCBNET::Spritesets::Block::paddingBottom, avg 11µs/call
88 # only optimize top edge/stack
891281.42ms1281.31ms unless ($self->alignOpp)
# spent 1.31ms making 128 calls to OCBNET::Spritesets::Stack::alignOpp, avg 10µs/call
90 {
91 # keep top margin if repeating
92 # unless ($sprite->isRepeatY)
9380841µs80825µs { $sprite->paddingTop = 0; }
# spent 825µs making 80 calls to OCBNET::Spritesets::Block::paddingTop, avg 10µs/call
94 }
95 }
96 }
97 }
98 # EO each sprite
99
100 # call container layout
101 # calls layout on sprites
102962.95ms96369ms $self->SUPER::layout;
# spent 369ms making 96 calls to OCBNET::Spritesets::Container::layout, avg 3.84ms/call
103
104 # declare positions
10596247µs my ($top, $left) = (0, 0);
106
107 # declare dimensions
10896168µs my ($width, $height) = (0, 0);
109
110 # process all sprites for layout
111961.57ms961.25ms foreach my $sprite ($self->children)
# spent 1.25ms making 96 calls to OCBNET::Spritesets::Container::children, avg 13µs/call
112 {
113
114 # get the sprite outer dimensions
1154364.73ms43635.3ms my $sprite_width = $sprite->outerWidth;
# spent 35.3ms making 436 calls to OCBNET::Spritesets::Block::outerWidth, avg 81µs/call
1164364.66ms43634.8ms my $sprite_height = $sprite->outerHeight;
# spent 34.8ms making 436 calls to OCBNET::Spritesets::Block::outerHeight, avg 80µs/call
117
118 # stack sprites vertically
1194365.04ms4364.59ms if ($self->stackVert)
# spent 4.59ms making 436 calls to OCBNET::Spritesets::Stack::stackVert, avg 11µs/call
120 {
121 # increase the stack height
122212293µs $height += $sprite_height;
123 # search biggest sprite width
124212387µs if ($width < $sprite_width)
125 { $width = $sprite_width; }
126 }
127 # or stack sprites horizontally
128 else
129 {
130 # increase the stack width
131224328µs $width += $sprite_width;
132 # search biggest sprite height
133224388µs if ($height < $sprite_height)
134 { $height = $sprite_height; }
135 }
136
137 # store sprite position
1384364.39ms4364.45ms $sprite->left = $left;
# spent 4.45ms making 436 calls to OCBNET::Spritesets::Block::left, avg 10µs/call
1394364.33ms4364.39ms $sprite->top = $top;
# spent 4.39ms making 436 calls to OCBNET::Spritesets::Block::top, avg 10µs/call
140
141 # increase the offset
1424366.09ms4364.31ms if ($self->stackVert)
# spent 4.31ms making 436 calls to OCBNET::Spritesets::Stack::stackVert, avg 10µs/call
143 { $top += $sprite_height; }
144224419µs else { $left += $sprite_width; }
145
146 }
147 # EO each sprite
148
149 # store dimensions
150961.12ms961.05ms $self->width = $width;
# spent 1.05ms making 96 calls to OCBNET::Spritesets::Block::width, avg 11µs/call
151961.04ms96976µs $self->height = $height;
# spent 976µs making 96 calls to OCBNET::Spritesets::Block::height, avg 10µs/call
152
153 # return here if no alignment is set
154961.69ms961.06ms return $self unless $self->alignOpp;
# spent 1.06ms making 96 calls to OCBNET::Spritesets::Stack::alignOpp, avg 11µs/call
155
156 # process all sprites for alignment
15748777µs48620µs foreach my $sprite ($self->children)
# spent 620µs making 48 calls to OCBNET::Spritesets::Container::children, avg 13µs/call
158 {
159 # stacks sprites vertically
1602646.82ms62422.8ms if ($self->stackVert)
# spent 18.9ms making 240 calls to OCBNET::Spritesets::Block::outerWidth, avg 79µs/call # spent 2.71ms making 264 calls to OCBNET::Spritesets::Stack::stackVert, avg 10µs/call # spent 1.18ms making 120 calls to OCBNET::Spritesets::Block::left, avg 10µs/call
161 {
162 # align this sprite to the oppositioning side
163 $sprite->left = $self->outerWidth - $sprite->outerWidth;
164 }
165 # stacks sprites horizontally
166 else
167 {
168 # align this sprite to the oppositioning side
1691444.17ms43224.2ms $sprite->top = $self->outerHeight - $sprite->outerHeight;
# spent 22.8ms making 288 calls to OCBNET::Spritesets::Block::outerHeight, avg 79µs/call # spent 1.47ms making 144 calls to OCBNET::Spritesets::Block::top, avg 10µs/call
170 }
171 }
172
173 # allow chaining
17448768µs return $self;
175
176}
177# EO sub layout
178
179####################################################################################################
180####################################################################################################
181114µs1;