Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/Spritesets/Fit.pm |
Statements | Executed 12943 statements in 114ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
12 | 1 | 1 | 307ms | 91.2s | layout | OCBNET::Spritesets::Fit::
1 | 1 | 1 | 83µs | 185µs | BEGIN@11 | OCBNET::Spritesets::Fit::
1 | 1 | 1 | 58µs | 92µs | BEGIN@12 | OCBNET::Spritesets::Fit::
1 | 1 | 1 | 52µs | 489µs | BEGIN@17 | OCBNET::Spritesets::Fit::
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 a block where all sprites get fitted in | ||||
6 | # the smallest available space (see packing module) | ||||
7 | #################################################################################################### | ||||
8 | package OCBNET::Spritesets::Fit; | ||||
9 | #################################################################################################### | ||||
10 | |||||
11 | 2 | 178µs | 2 | 287µs | # spent 185µs (83+102) within OCBNET::Spritesets::Fit::BEGIN@11 which was called:
# once (83µs+102µs) by OCBNET::Spritesets::BEGIN@30 at line 11 # spent 185µs making 1 call to OCBNET::Spritesets::Fit::BEGIN@11
# spent 102µs making 1 call to strict::import |
12 | 2 | 166µs | 2 | 126µs | # spent 92µs (58+34) within OCBNET::Spritesets::Fit::BEGIN@12 which was called:
# once (58µs+34µs) by OCBNET::Spritesets::BEGIN@30 at line 12 # spent 92µs making 1 call to OCBNET::Spritesets::Fit::BEGIN@12
# spent 34µs making 1 call to warnings::import |
13 | |||||
14 | #################################################################################################### | ||||
15 | |||||
16 | # a container is also a block | ||||
17 | 2 | 933µs | 2 | 926µs | # spent 489µs (52+437) within OCBNET::Spritesets::Fit::BEGIN@17 which was called:
# once (52µs+437µs) by OCBNET::Spritesets::BEGIN@30 at line 17 # spent 489µs making 1 call to OCBNET::Spritesets::Fit::BEGIN@17
# spent 437µs making 1 call to base::import |
18 | |||||
19 | #################################################################################################### | ||||
20 | |||||
21 | # calculate positions and dimensions | ||||
22 | # ****************************************************************************** | ||||
23 | sub layout | ||||
24 | # spent 91.2s (307ms+90.9) within OCBNET::Spritesets::Fit::layout which was called 12 times, avg 7.60s/call:
# 12 times (307ms+90.9s) by OCBNET::Spritesets::Canvas::Layout::layout at line 108 of webmerge/scripts/modules/OCBNET/Spritesets/Canvas/Layout.pm, avg 7.60s/call | ||||
25 | |||||
26 | # get our object | ||||
27 | 12 | 37µs | my ($self) = @_; | ||
28 | |||||
29 | # do nothing if empty | ||||
30 | 12 | 138µs | 12 | 154µs | return if $self->empty; # spent 154µs making 12 calls to OCBNET::Spritesets::Container::empty, avg 13µs/call |
31 | |||||
32 | 12 | 381µs | 12 | 3.57s | $self->SUPER::layout; # spent 3.57s making 12 calls to OCBNET::Spritesets::Container::layout, avg 297ms/call |
33 | |||||
34 | # create the packer object for composition | ||||
35 | 12 | 346µs | 12 | 218µs | my $packer = new OCBNET::Packer::2D; # spent 218µs making 12 calls to OCBNET::Packer::2D::new, avg 18µs/call |
36 | |||||
37 | # fit the rectangles/images | ||||
38 | 12 | 164µs | 12 | 87.3s | $packer->fit($self->{'children'}); # spent 87.3s making 12 calls to OCBNET::Packer::2D::fit, avg 7.27s/call |
39 | |||||
40 | # get the dimensions for the image and store on block | ||||
41 | 12 | 259µs | 12 | 187µs | $self->width = $packer->{'root'}->{'width'}; # spent 187µs making 12 calls to OCBNET::Spritesets::Block::width, avg 16µs/call |
42 | 12 | 176µs | 12 | 144µs | $self->height = $packer->{'root'}->{'height'}; # spent 144µs making 12 calls to OCBNET::Spritesets::Block::height, avg 12µs/call |
43 | |||||
44 | # process and update rectangles/images | ||||
45 | 12 | 118µs | foreach my $sprite (@{$self->{'children'}}) | ||
46 | { | ||||
47 | |||||
48 | # this should never happen, but catch anyway | ||||
49 | # we optimize the input so this should be impossible | ||||
50 | 4276 | 10.4ms | die "fatal: sprite could not be fitted" unless $sprite->{'fit'}; | ||
51 | |||||
52 | # update the positions for the sprites | ||||
53 | 4276 | 44.0ms | 4276 | 42.2ms | $sprite->top = $sprite->{'fit'}->{'y'}; # spent 42.2ms making 4276 calls to OCBNET::Spritesets::Block::top, avg 10µs/call |
54 | 4276 | 55.5ms | 4276 | 40.0ms | $sprite->left = $sprite->{'fit'}->{'x'}; # spent 40.0ms making 4276 calls to OCBNET::Spritesets::Block::left, avg 9µs/call |
55 | |||||
56 | } | ||||
57 | # EO each sprite | ||||
58 | |||||
59 | # return instance | ||||
60 | 12 | 1.30ms | return $self; | ||
61 | |||||
62 | } | ||||
63 | # EO sub layout | ||||
64 | |||||
65 | #################################################################################################### | ||||
66 | #################################################################################################### | ||||
67 | 1 | 12µs | 1; |