line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Sample::SQL::Slow; |
2
|
2
|
|
|
2
|
|
35053
|
use 5.008005; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
87
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
21
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
1307
|
use Data::Dumper; |
|
2
|
|
|
|
|
6588
|
|
|
2
|
|
|
|
|
805
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
0
|
31
|
my ($class, %opt) = @_; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
33
|
|
|
33
|
bless { |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
13
|
|
|
|
|
|
|
time => $opt{time} || time, |
14
|
|
|
|
|
|
|
user => $opt{user} || "hoge", |
15
|
|
|
|
|
|
|
host => $opt{host} || "localhost", |
16
|
|
|
|
|
|
|
id => $opt{id} || int(rand() * 100000), |
17
|
|
|
|
|
|
|
query_time => $opt{query_time} || rand() + 3, |
18
|
|
|
|
|
|
|
lock_time => $opt{lock_time} || rand(), |
19
|
|
|
|
|
|
|
rows_sent => $opt{rows_sent} || int(rand() * 1000000), |
20
|
|
|
|
|
|
|
rows_examined => $opt{rows_examined} || int(rand() * 1000000), |
21
|
|
|
|
|
|
|
query => $opt{query} || $class->queryBuild(%opt), |
22
|
|
|
|
|
|
|
}, $class; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub toStr { |
26
|
1
|
|
|
1
|
0
|
7
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
46
|
"# Time: $self->{time}\n". |
29
|
|
|
|
|
|
|
"# User\@Host: $self->{user}\[$self->{user}\] @ $self->{host} [] Id: $self->{id}\n". |
30
|
|
|
|
|
|
|
"# Query_time: $self->{query_time} Lock_time: $self->{lock_time} Rows_sent: $self->{rows_sent} Rows_examined: $self->{rows_examined}\n". |
31
|
|
|
|
|
|
|
"SET timestamp=$self->{time}\n". |
32
|
|
|
|
|
|
|
"$self->{query}"; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub queryBuild { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, %opt) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @tables = qw/users posts comments blogs/; |
39
|
0
|
|
|
|
|
|
my @queries = qw/select/; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
0
|
|
|
|
my $table = $opt{table} || $tables[int(rand() * scalar @tables)]; |
42
|
0
|
|
0
|
|
|
|
my $query = $opt{query} || $queries[int(rand() * scalar @queries)]; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if($query eq "select"){ |
45
|
0
|
|
|
|
|
|
"SELECT * FROM $table WHERE name LIKE \"\%hoge\%\" AND updatedAt > ".time; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |