| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XAO::testcases::FS::index; |
|
2
|
1
|
|
|
1
|
|
627
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
3
|
1
|
|
|
1
|
|
503
|
use XAO::Utils; |
|
|
1
|
|
|
|
|
18989
|
|
|
|
1
|
|
|
|
|
68
|
|
|
4
|
1
|
|
|
1
|
|
479
|
use XAO::Objects; |
|
|
1
|
|
|
|
|
5451
|
|
|
|
1
|
|
|
|
|
31
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use Error qw(:try); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
129
|
use base qw(XAO::testcases::FS::base); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
444
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub test_index_int { |
|
10
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
11
|
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $odb=$self->get_odb(); |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $testq=2000; |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $clist=$odb->fetch('/Customers'); |
|
17
|
0
|
|
|
|
|
|
my $cust=$clist->get_new(); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
## |
|
20
|
|
|
|
|
|
|
# Just some stuff to make records longer |
|
21
|
|
|
|
|
|
|
# |
|
22
|
0
|
|
|
|
|
|
$cust->add_placeholder(name => 'text', |
|
23
|
|
|
|
|
|
|
type => 'text', |
|
24
|
|
|
|
|
|
|
maxlength => 1000); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## |
|
27
|
|
|
|
|
|
|
# Normal search |
|
28
|
|
|
|
|
|
|
# |
|
29
|
0
|
|
|
|
|
|
$cust->add_placeholder(name => 'int', |
|
30
|
|
|
|
|
|
|
type => 'integer', |
|
31
|
|
|
|
|
|
|
minvalue => 0, |
|
32
|
|
|
|
|
|
|
maxvalue => $testq); |
|
33
|
0
|
|
|
|
|
|
my ($fill_normal,$s1_normal,$s2_normal)=$self->measure_integer($testq,$clist); |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$cust->drop_placeholder('int'); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
## |
|
38
|
|
|
|
|
|
|
# Indexed search |
|
39
|
|
|
|
|
|
|
# |
|
40
|
0
|
|
|
|
|
|
$cust->add_placeholder(name => 'int', |
|
41
|
|
|
|
|
|
|
type => 'integer', |
|
42
|
|
|
|
|
|
|
minvalue => 0, |
|
43
|
|
|
|
|
|
|
maxvalue => $testq, |
|
44
|
|
|
|
|
|
|
index => 1); |
|
45
|
0
|
|
|
|
|
|
my ($fill_index,$s1_index,$s2_index)=$self->measure_integer($testq,$clist); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
## |
|
48
|
|
|
|
|
|
|
# Do we need this kind of checks for real programs? This has to do |
|
49
|
|
|
|
|
|
|
# only with speed optimisations, functionality is not affected.. |
|
50
|
|
|
|
|
|
|
# |
|
51
|
0
|
0
|
|
|
|
|
return 0 if $odb->_driver->{no_null_indexes}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#dprint "Normal: $fill_normal $s1_normal $s2_normal"; |
|
54
|
|
|
|
|
|
|
#dprint "Index: $fill_index $s1_index $s2_index"; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$self->assert($s1_index<=$s1_normal, |
|
57
|
|
|
|
|
|
|
"Indexed search takes longer then normal ($s1_index>$s1_normal)"); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub measure_integer { |
|
61
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
62
|
0
|
|
|
|
|
|
my $testq=shift; |
|
63
|
0
|
|
|
|
|
|
my $clist=shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$clist->destroy; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $cust=$clist->get_new(); |
|
68
|
0
|
|
|
|
|
|
$cust->put(text => 'Z' x 1000); |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $before_fill=$self->timestamp; |
|
71
|
0
|
|
|
|
|
|
my @xx; |
|
72
|
0
|
|
|
|
|
|
$cust->glue->transact_begin; |
|
73
|
0
|
|
|
|
|
|
for(my $i=0; $i!=$testq; $i++) { |
|
74
|
0
|
|
|
|
|
|
$cust->put(int => $i); |
|
75
|
0
|
|
|
|
|
|
push(@xx,$clist->put($cust)); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
0
|
|
|
|
|
|
$cust->glue->transact_commit; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $list; |
|
80
|
0
|
|
|
|
|
|
my $before_search_1=$self->timestamp; |
|
81
|
0
|
|
|
|
|
|
srand 0; |
|
82
|
0
|
|
|
|
|
|
for(1..500) { |
|
83
|
0
|
|
|
|
|
|
$list=$clist->search('int', 'eq', int(rand($testq))); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
|
|
|
|
|
my $after_search_1=$self->timestamp; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->assert(@$list==1, |
|
88
|
|
|
|
|
|
|
"Returned wrong number of objects in fill_and_measure"); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $before_search_range=$self->timestamp; |
|
91
|
0
|
|
|
|
|
|
for(1..100) { |
|
92
|
0
|
|
|
|
|
|
my $lower=int(rand($testq*2/3)); |
|
93
|
0
|
|
|
|
|
|
my $upper=$lower+int(rand($testq/3)); |
|
94
|
0
|
|
|
|
|
|
$list=$clist->search([ 'int', 'ge', $lower ], |
|
95
|
|
|
|
|
|
|
'and', |
|
96
|
|
|
|
|
|
|
[ 'int', 'lt', $upper ]); |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $got=scalar(@$list); |
|
99
|
0
|
|
|
|
|
|
my $should=$upper-$lower; |
|
100
|
0
|
|
|
|
|
|
$self->assert($got==$should, |
|
101
|
|
|
|
|
|
|
"Returned wrong number of objects for range ($got!=$should)"); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
0
|
|
|
|
|
|
my $after_search_range=$self->timestamp; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
( $self->timediff($before_search_1,$before_fill), |
|
106
|
|
|
|
|
|
|
$self->timediff($after_search_1,$before_search_1), |
|
107
|
|
|
|
|
|
|
$self->timediff($after_search_range,$before_search_range) |
|
108
|
|
|
|
|
|
|
); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |