line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::LoadGen::ScoreBoard; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
24184
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
4
|
2
|
|
|
2
|
|
1588
|
use IPC::ScoreBoard; |
|
2
|
|
|
|
|
31126
|
|
|
2
|
|
|
|
|
15
|
|
5
|
2
|
|
|
2
|
|
418
|
no warnings 'uninitialized'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
257
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
14
|
use Exporter qw/import/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
783
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK=qw/scoreboard sb slot thread_start thread_done req_start |
11
|
|
|
|
|
|
|
req_done thread_count req_started req_success req_failed |
12
|
|
|
|
|
|
|
header_bytes header_count body_bytes sbinit/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use constant { |
15
|
2
|
|
|
|
|
4222
|
SC_THREADCOUNT=>0, # scoreboard items |
16
|
|
|
|
|
|
|
SC_REQ_STARTED=>1, |
17
|
|
|
|
|
|
|
SC_REQ_SUCCESS=>2, |
18
|
|
|
|
|
|
|
SC_REQ_FAILED=>3, |
19
|
|
|
|
|
|
|
SC_BODY_BYTES=>4, |
20
|
|
|
|
|
|
|
SC_HEADER_BYTES=>5, |
21
|
|
|
|
|
|
|
SC_HEADER_COUNT=>6, |
22
|
|
|
|
|
|
|
SC_SLOTSIZE=>7, |
23
|
2
|
|
|
2
|
|
16
|
}; |
|
2
|
|
|
|
|
3
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my ($scoreboard, $slotsz, $extra, $myslot); |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
1
|
66
|
sub scoreboard () : lvalue {$scoreboard;} |
28
|
12
|
|
|
12
|
1
|
478
|
sub slot () : lvalue {$myslot;} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
BEGIN { |
31
|
2
|
50
|
|
2
|
|
32
|
if( SB::have_atomics ) { |
32
|
|
|
|
|
|
|
*init=sub { |
33
|
2
|
|
|
2
|
|
203
|
(my ($name, $nslots), $slotsz, $extra)=@_; |
34
|
2
|
100
|
|
|
|
7
|
if( defined $name ) { |
35
|
1
|
|
|
|
|
8
|
$scoreboard=SB::named $name, 0+$nslots, 0+$slotsz, $extra+SC_SLOTSIZE; |
36
|
|
|
|
|
|
|
} else { |
37
|
1
|
|
|
|
|
7
|
$scoreboard=SB::anon 0+$nslots, 0+$slotsz, $extra+SC_SLOTSIZE; |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
|
|
|
482
|
return $scoreboard; |
40
|
2
|
|
|
|
|
14
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
*thread_start=sub () { |
43
|
4
|
|
|
4
|
|
29
|
SB::incr_extra $scoreboard, $extra+SC_THREADCOUNT; |
44
|
2
|
|
|
|
|
7
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
*thread_done=sub () { |
47
|
1
|
|
|
1
|
|
9
|
SB::decr_extra $scoreboard, $extra+SC_THREADCOUNT; |
48
|
2
|
|
|
|
|
7
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
*req_start=sub () { |
51
|
4
|
|
|
4
|
|
33
|
SB::incr_extra $scoreboard, $extra+SC_REQ_STARTED; |
52
|
2
|
|
|
|
|
12
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
*req_done=sub ($$$) { |
55
|
3
|
|
|
3
|
|
21
|
my ($success, $hdr, $body)=@_; |
56
|
3
|
100
|
|
|
|
13
|
SB::incr_extra $scoreboard, |
57
|
|
|
|
|
|
|
$extra+($success ? SC_REQ_SUCCESS : SC_REQ_FAILED); |
58
|
3
|
|
|
|
|
7
|
SB::incr_extra $scoreboard, $extra+SC_BODY_BYTES, length $body; |
59
|
3
|
|
|
|
|
9
|
SB::incr_extra $scoreboard, $extra+SC_HEADER_COUNT, 0+keys %$hdr; |
60
|
3
|
|
|
|
|
4
|
my $sum=0; |
61
|
3
|
|
|
|
|
13
|
while( my ($k, $v)=each %$hdr ) { |
62
|
6
|
|
|
|
|
7
|
$sum+=length $k; |
63
|
6
|
|
|
|
|
8
|
for my $s (@$v) { |
64
|
6
|
|
|
|
|
23
|
$sum+=length $s; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
3
|
|
|
|
|
10
|
SB::incr_extra $scoreboard, $extra+SC_HEADER_BYTES, $sum; |
68
|
2
|
|
|
|
|
12
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
*thread_count=sub () { |
71
|
2
|
|
|
2
|
|
13
|
SB::get_extra $scoreboard, $extra+SC_THREADCOUNT; |
72
|
2
|
|
|
|
|
13
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
*req_started=sub () { |
75
|
2
|
|
|
2
|
|
20
|
SB::get_extra $scoreboard, $extra+SC_REQ_STARTED; |
76
|
2
|
|
|
|
|
5
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
*req_success=sub () { |
79
|
2
|
|
|
2
|
|
10
|
SB::get_extra $scoreboard, $extra+SC_REQ_SUCCESS; |
80
|
2
|
|
|
|
|
7
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*req_failed=sub () { |
83
|
2
|
|
|
2
|
|
11
|
SB::get_extra $scoreboard, $extra+SC_REQ_FAILED; |
84
|
2
|
|
|
|
|
6
|
}; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
*header_bytes=sub () { |
87
|
2
|
|
|
2
|
|
13
|
SB::get_extra $scoreboard, $extra+SC_HEADER_BYTES; |
88
|
2
|
|
|
|
|
6
|
}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
*header_count=sub () { |
91
|
2
|
|
|
2
|
|
13
|
SB::get_extra $scoreboard, $extra+SC_HEADER_COUNT; |
92
|
2
|
|
|
|
|
12
|
}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
*body_bytes=sub () { |
95
|
2
|
|
|
2
|
|
14
|
SB::get_extra $scoreboard, $extra+SC_BODY_BYTES; |
96
|
2
|
|
|
|
|
118
|
}; |
97
|
|
|
|
|
|
|
} else { # no atomics |
98
|
|
|
|
|
|
|
*init=sub { |
99
|
0
|
|
|
|
|
0
|
(my ($name, $nslots), $slotsz, $extra)=@_; |
100
|
0
|
0
|
|
|
|
0
|
if( defined $name ) { |
101
|
0
|
|
|
|
|
0
|
$scoreboard=SB::named $name, 0+$nslots, 0+$slotsz+SC_SLOTSIZE, 0+$extra; |
102
|
|
|
|
|
|
|
} else { |
103
|
0
|
|
|
|
|
0
|
$scoreboard=SB::anon 0+$nslots, 0+$slotsz+SC_SLOTSIZE, 0+$extra; |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
0
|
return $scoreboard; |
106
|
0
|
|
|
|
|
0
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
*thread_start=sub () { |
109
|
0
|
|
|
|
|
0
|
SB::incr $scoreboard, $myslot, $slotsz+SC_THREADCOUNT; |
110
|
0
|
|
|
|
|
0
|
}; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
*thread_done=sub () { |
113
|
0
|
|
|
|
|
0
|
SB::decr $scoreboard, $myslot, $slotsz+SC_THREADCOUNT; |
114
|
0
|
|
|
|
|
0
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
*req_start=sub () { |
117
|
0
|
|
|
|
|
0
|
SB::incr $scoreboard, $myslot, $slotsz+SC_REQ_STARTED; |
118
|
0
|
|
|
|
|
0
|
}; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
*req_done=sub ($$$) { |
121
|
0
|
|
|
|
|
0
|
my ($success, $hdr, $body)=@_; |
122
|
0
|
0
|
|
|
|
0
|
SB::incr $scoreboard, $myslot, |
123
|
|
|
|
|
|
|
$slotsz+($success ? SC_REQ_SUCCESS : SC_REQ_FAILED); |
124
|
0
|
|
|
|
|
0
|
SB::incr $scoreboard, $myslot, $slotsz+SC_BODY_BYTES, length $body; |
125
|
0
|
|
|
|
|
0
|
SB::incr $scoreboard, $myslot, $slotsz+SC_HEADER_COUNT, 0+keys %$hdr; |
126
|
0
|
|
|
|
|
0
|
my $sum=0; |
127
|
0
|
|
|
|
|
0
|
while( my ($k, $v)=each %$hdr ) { |
128
|
0
|
|
|
|
|
0
|
$sum+=length $k; |
129
|
0
|
|
|
|
|
0
|
for my $s (@$v) { |
130
|
0
|
|
|
|
|
0
|
$sum+=length $s; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
0
|
SB::incr $scoreboard, $myslot, $slotsz+SC_HEADER_BYTES, $sum; |
134
|
0
|
|
|
|
|
0
|
}; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
*thread_count=sub () { |
137
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_THREADCOUNT; |
138
|
0
|
|
|
|
|
0
|
}; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
*req_started=sub () { |
141
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_REQ_STARTED; |
142
|
0
|
|
|
|
|
0
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
*req_success=sub () { |
145
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_REQ_SUCCESS; |
146
|
0
|
|
|
|
|
0
|
}; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
*req_failed=sub () { |
149
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_REQ_FAILED; |
150
|
0
|
|
|
|
|
0
|
}; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
*header_bytes=sub () { |
153
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_HEADER_BYTES; |
154
|
0
|
|
|
|
|
0
|
}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
*header_count=sub () { |
157
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_HEADER_COUNT; |
158
|
0
|
|
|
|
|
0
|
}; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
*body_bytes=sub () { |
161
|
0
|
|
|
|
|
0
|
SB::sum $scoreboard, $slotsz+SC_BODY_BYTES; |
162
|
0
|
|
|
|
|
0
|
}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
*sbinit=\&init; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |
169
|
|
|
|
|
|
|
__END__ |