line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::KYTProf::Profiler::Redis::Fast; |
2
|
2
|
|
|
2
|
|
1557
|
use 5.012001; |
|
2
|
|
|
|
|
6
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
5
|
2
|
|
|
2
|
|
560
|
use Redis::Fast; |
|
2
|
|
|
|
|
18397
|
|
|
2
|
|
|
|
|
793
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub strip { |
10
|
0
|
|
|
0
|
0
|
0
|
my $s = shift; |
11
|
0
|
0
|
|
|
|
0
|
if (length($s) > 255) { |
12
|
0
|
|
|
|
|
0
|
return substr($s, 0, 252) . "..."; |
13
|
|
|
|
|
|
|
} |
14
|
0
|
|
|
|
|
0
|
return $s; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub apply { |
18
|
|
|
|
|
|
|
# command for a key |
19
|
|
|
|
|
|
|
Devel::KYTProf->add_prof( |
20
|
|
|
|
|
|
|
'Redis::Fast', |
21
|
|
|
|
|
|
|
'__std_cmd', |
22
|
|
|
|
|
|
|
sub { |
23
|
0
|
|
|
0
|
|
0
|
my ($orig, $self, $cmd, @args) = @_; |
24
|
0
|
|
|
|
|
0
|
my $data = { |
25
|
|
|
|
|
|
|
command => uc($cmd), |
26
|
|
|
|
|
|
|
}; |
27
|
0
|
0
|
0
|
|
|
0
|
if (lc($cmd) =~ /get/ && lc($cmd) ne "getset") { |
28
|
0
|
|
|
|
|
0
|
$data->{key} = strip(join(" ", @args)); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
0
|
0
|
|
|
|
0
|
$data->{key} = @args > 0 ? strip($args[0]) : ""; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
return [ |
34
|
0
|
|
|
|
|
0
|
'%s %s', |
35
|
|
|
|
|
|
|
['command', 'key'], |
36
|
|
|
|
|
|
|
$data, |
37
|
|
|
|
|
|
|
]; |
38
|
|
|
|
|
|
|
}, |
39
|
1
|
|
|
1
|
0
|
37
|
); |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
132
|
for my $cmd (qw/ ping quit shutdown keys select info subscribe psubscribe unsubscribe punsubscribe /) { |
42
|
|
|
|
|
|
|
Devel::KYTProf->add_prof( |
43
|
|
|
|
|
|
|
'Redis::Fast', |
44
|
|
|
|
|
|
|
$cmd, |
45
|
|
|
|
|
|
|
sub { |
46
|
0
|
|
|
0
|
|
|
my ($orig, $self, @args) = @_; |
47
|
0
|
|
|
|
|
|
my $data = { |
48
|
|
|
|
|
|
|
command => uc($cmd), |
49
|
|
|
|
|
|
|
}; |
50
|
0
|
0
|
|
|
|
|
if (@args > 0) { |
51
|
0
|
0
|
|
|
|
|
if ($cmd =~ /subscribe/) { |
52
|
0
|
|
|
|
|
|
pop @args; # remove subref |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
|
$data->{args} = strip(join(" ", @args)); |
55
|
0
|
|
|
|
|
|
return ['%s %s', ['command', 'args'], $data]; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
return ['%s', ['command'], $data]; |
58
|
|
|
|
|
|
|
}, |
59
|
10
|
|
|
|
|
870
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |