← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:36 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Form/Checkbox.pm
StatementsExecuted 15 statements in 1.02ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11187µs164µsFoswiki::Form::Checkbox::::newFoswiki::Form::Checkbox::new
11142µs57µsFoswiki::Form::Checkbox::::BEGIN@4Foswiki::Form::Checkbox::BEGIN@4
11132µs67µsFoswiki::Form::Checkbox::::BEGIN@5Foswiki::Form::Checkbox::BEGIN@5
11115µs15µsFoswiki::Form::Checkbox::::BEGIN@7Foswiki::Form::Checkbox::BEGIN@7
1112µs2µsFoswiki::Form::Checkbox::::CORE:substFoswiki::Form::Checkbox::CORE:subst (opcode)
0000s0sFoswiki::Form::Checkbox::::getDefaultValueFoswiki::Form::Checkbox::getDefaultValue
0000s0sFoswiki::Form::Checkbox::::isMultiValuedFoswiki::Form::Checkbox::isMultiValued
0000s0sFoswiki::Form::Checkbox::::renderForEditFoswiki::Form::Checkbox::renderForEdit
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2package Foswiki::Form::Checkbox;
3
4270µs271µs
# spent 57µs (42+14) within Foswiki::Form::Checkbox::BEGIN@4 which was called: # once (42µs+14µs) by Foswiki::Form::createField at line 4
use strict;
# spent 57µs making 1 call to Foswiki::Form::Checkbox::BEGIN@4 # spent 14µs making 1 call to strict::import
5265µs2102µs
# spent 67µs (32+35) within Foswiki::Form::Checkbox::BEGIN@5 which was called: # once (32µs+35µs) by Foswiki::Form::createField at line 5
use warnings;
# spent 67µs making 1 call to Foswiki::Form::Checkbox::BEGIN@5 # spent 35µs making 1 call to warnings::import
6
72771µs115µs
# spent 15µs within Foswiki::Form::Checkbox::BEGIN@7 which was called: # once (15µs+0s) by Foswiki::Form::createField at line 7
use Foswiki::Form::ListFieldDefinition ();
# spent 15µs making 1 call to Foswiki::Form::Checkbox::BEGIN@7
8125µsour @ISA = ('Foswiki::Form::ListFieldDefinition');
9
10
# spent 164µs (87+77) within Foswiki::Form::Checkbox::new which was called: # once (87µs+77µs) by Foswiki::Form::createField at line 311 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Form.pm
sub new {
11787µs my ( $class, @args ) = @_;
12174µs my $this = $class->SUPER::new(@args);
# spent 74µs making 1 call to Foswiki::Form::FieldDefinition::new
13 $this->{size} ||= 0;
1412µs $this->{size} =~ s/\D//g;
# spent 2µs making 1 call to Foswiki::Form::Checkbox::CORE:subst
15 $this->{size} ||= 0;
16 $this->{size} = 4 if ( $this->{size} < 1 );
17
18 return $this;
19}
20
21# Checkboxes can't provide a default from the form spec
22sub getDefaultValue { return; }
23
24# Checkbox store multiple values
25sub isMultiValued { return 1; }
26
27sub renderForEdit {
28 my ( $this, $topicObject, $value ) = @_;
29
30 my $session = $this->{session};
31 my $extra = '';
32 if ( $this->{type} =~ m/\+buttons/ ) {
33 my $boxes = scalar( @{ $this->getOptions() } );
34 $extra = CGI::br();
35 $extra .= CGI::button(
36 -class => 'foswikiCheckbox',
37 -value => $session->i18n->maketext('Set all'),
38 -onClick => 'checkAll(this,2,' . $boxes . ',true)'
39 );
40 $extra .= '&nbsp;';
41 $extra .= CGI::button(
42 -class => 'foswikiCheckbox',
43 -value => $session->i18n->maketext('Clear all'),
44 -onClick => 'checkAll(this,1,' . $boxes . ',false)'
45 );
46 }
47 $value = '' unless defined($value) && length($value);
48 my %isSelected = map { $_ => 1 } split( /\s*,\s*/, $value );
49 my %attrs;
50 foreach my $item ( @{ $this->getOptions() } ) {
51
52 # NOTE: Does not expand $item in title
53 $attrs{$item} = {
54 class => $this->cssClasses('foswikiCheckbox'),
55 title => $topicObject->expandMacros($item),
56 };
57
58 if ( $isSelected{$item} ) {
59 $attrs{$item}{checked} = 'checked';
60 }
61 }
62 $value = CGI::checkbox_group(
63 -name => $this->{name},
64 -values => $this->getOptions(),
65 -columns => $this->{size},
66 -attributes => \%attrs
67 );
68
69 # Item2410: We need a dummy control to detect the case where
70 # all checkboxes have been deliberately unchecked
71 # Item3061:
72 # Don't use CGI, it will insert the sticky value from the query
73 # once again and we need an empty field here.
74 $value .= '<input type="hidden" name="' . $this->{name} . '" value="" />';
75 return ( $extra, $value );
76}
77
7816µs1;
79__END__
 
# spent 2µs within Foswiki::Form::Checkbox::CORE:subst which was called: # once (2µs+0s) by Foswiki::Form::Checkbox::new at line 14
sub Foswiki::Form::Checkbox::CORE:subst; # opcode