~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/kewpie/sql-bench/as3ap

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# Copyright (C) 2001, 2003 MySQL AB
 
3
#
 
4
# This library is free software; you can redistribute it and/or
 
5
# modify it under the terms of the GNU Library General Public
 
6
# License as published by the Free Software Foundation; version 2
 
7
# of the License.
 
8
#
 
9
# This library is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
# Library General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Library General Public
 
15
# License along with this library; if not, write to the Free
 
16
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
17
# MA 02111-1307, USA
 
18
#
 
19
# AS3AP single-user benchmark.
 
20
#
 
21
 
 
22
##################### Standard benchmark inits ##############################
 
23
 
 
24
use Cwd;
 
25
use DBI;
 
26
use Benchmark;
 
27
 
 
28
$pwd = cwd(); $pwd = "." if ($pwd eq '');
 
29
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
 
30
 
 
31
$opt_loop_count=1;
 
32
 
 
33
#Create tables 
 
34
 
 
35
$dbh = $server->connect();
 
36
 
 
37
#Create Table
 
38
$sth = $dbh->do("drop table uniques");
 
39
$sth = $dbh->do("drop table updates");
 
40
$sth = $dbh->do("drop table hundred");
 
41
$sth = $dbh->do("drop table tenpct");
 
42
$sth = $dbh->do("drop table tiny");
 
43
 
 
44
#Temporary table
 
45
$sth = $dbh->do("drop table saveupdates");
 
46
 
 
47
@fields=("col_key     int             not null",
 
48
         "col_int     int             not null",
 
49
         "col_signed  int             not null",
 
50
         "col_float   float           not null",
 
51
         "col_double  float           not null",
 
52
         "col_decim   numeric(18,2)   not null",
 
53
         "col_date    char(20)        not null",
 
54
         "col_code    char(10)        not null",
 
55
         "col_name    char(20)        not null",
 
56
         "col_address varchar(80)     not null");
 
57
 
 
58
do_many($dbh,$server->create("uniques",\@fields,[]));
 
59
do_many($dbh,$server->create("updates",\@fields,[]));
 
60
do_many($dbh,$server->create("hundred",\@fields,[]));
 
61
do_many($dbh,$server->create("tenpct",\@fields,[]));
 
62
do_many($dbh,$server->create("tiny",["col_key int not null"],[]));
 
63
 
 
64
print "Start AS3AP benchmark\n\n";
 
65
 
 
66
$start_time=new Benchmark;
 
67
 
 
68
print "Load DATA\n";
 
69
#Load DATA
 
70
 
 
71
@table_names=("uniques","updates","hundred","tenpct","tiny");
 
72
 
 
73
$loop_time=new Benchmark;
 
74
 
 
75
if ($opt_fast && $server->{'limits'}->{'load_data_infile'})
 
76
{
 
77
  for ($ti = 0; $ti <= $#table_names; $ti++)
 
78
  {
 
79
    my $table_name = $table_names[$ti];
 
80
    my $file = "$pwd/Data/AS3AP/${table_name}\.new";
 
81
    print "$table_name - $file\n" if ($opt_debug);
 
82
    $row_count += $server->insert_file($table_name,$file,$dbh);
 
83
  }
 
84
}
 
85
else
 
86
{
 
87
  for ($ti = 0; $ti <= $#table_names; $ti++)
 
88
  {
 
89
    my $table_name = $table_names[$ti];
 
90
    print "$table_name - $file\n" if ($opt_debug);
 
91
    my $insert_start = "insert into $table_name values (";
 
92
    open(DATA, "$pwd/Data/AS3AP/${table_name}\.new") || die "Can't open text file: $pwd/Data/AS3AP/${table_name}\.new\n";
 
93
    while(<DATA>)
 
94
    {
 
95
      chomp;
 
96
      next unless ( $_ =~ /\w/ );     # skip blank lines
 
97
      $command = $insert_start."$_".")";
 
98
      $command =~ $server->fix_to_insert($command);
 
99
      print "$command\n" if ($opt_debug);
 
100
      $sth = $dbh->do($command) or die "Got error: $DBI::errstr when executing '$command'\n";
 
101
          $row_count++;
 
102
    }
 
103
    close(DATA);
 
104
  }
 
105
}
 
106
 
 
107
$end_time=new Benchmark;
 
108
print "Time for Load Data - " . "($row_count): " .
 
109
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
 
110
 
 
111
 
 
112
print "Create Index\n";
 
113
 
 
114
test_command("create_idx_uniques_key_bt",
 
115
             "time for create_idx_uniques_key_bt",
 
116
             "create unique index uniques_key_bt on uniques (col_key)",$dbh,$opt_loop_count);
 
117
 
 
118
test_command("create_idx_updates_key_bt",
 
119
             "time for create_idx_updates_key_bt",
 
120
             "create unique index updates_key_bt on updates (col_key)",$dbh,$opt_loop_count);
 
121
 
 
122
test_command("create_idx_hundred_key_bt",
 
123
             "time for create_idx_hundred_key_bt",
 
124
             "create unique index hundred_key_bt on hundred (col_key)",
 
125
             $dbh,$opt_loop_count);
 
126
 
 
127
test_command("create_idx_tenpct_key_bt",
 
128
             "time for create_idx_tenpct_key_bt",
 
129
             "create unique index tenpct_key_bt on tenpct (col_key)",$dbh,$opt_loop_count);
 
130
 
 
131
test_command("create_idx_tenpct_key_code_bt",
 
132
             "time for create_idx_tenpct_key_code_bt",
 
133
             "create index tenpct_key_code_bt on tenpct (col_key,col_code)",
 
134
             $dbh,$opt_loop_count);
 
135
 
 
136
test_command("create_idx_tiny_key_bt",
 
137
             "time for create_idx_tiny_key_bt",
 
138
             "create index tiny_key_bt on tiny (col_key)",$dbh,$opt_loop_count);
 
139
 
 
140
test_command("create_idx_tenpct_int_bt",
 
141
             "time for create_idx_tenpct_int_bt",
 
142
             "create index tenpct_int_bt on tenpct (col_int)",$dbh,$opt_loop_count);
 
143
 
 
144
test_command("create_idx_tenpct_signed_bt",
 
145
             "time for create_idx_tenpct_signed_bt",
 
146
             "create index tenpct_signed_bt on tenpct (col_signed)",$dbh,$opt_loop_count);
 
147
 
 
148
test_command("create_idx_uniques_code_h",
 
149
             "time for create_idx_uniques_code_h",
 
150
             "create index uniques_code_h on uniques (col_code)",$dbh,$opt_loop_count);
 
151
 
 
152
test_command("create_idx_tenpct_double_bt",
 
153
             "time for create_idx_tenpct_double_bt",
 
154
             "create index tenpct_double_bt on tenpct (col_double)",$dbh,$opt_loop_count);
 
155
 
 
156
 
 
157
test_command("create_idx_updates_decim_bt",
 
158
             "time for create_idx_updates_decim_bt",
 
159
             "create index updates_decim_bt on updates (col_decim)",$dbh,$opt_loop_count);
 
160
 
 
161
test_command("create_idx_tenpct_float_bt",
 
162
             "time for create_idx_tenpct_float_bt",
 
163
             "create index tenpct_float_bt on tenpct (col_float)",$dbh,$opt_loop_count);
 
164
 
 
165
test_command("create_idx_updates_int_bt",
 
166
             "time for create_idx_updates_int_bt",
 
167
             "create index updates_int_bt on updates (col_int)",$dbh,$opt_loop_count);
 
168
 
 
169
test_command("create_idx_tenpct_decim_bt",
 
170
             "time for create_idx_tenpct_decim_bt",
 
171
             "create index tenpct_decim_bt on tenpct (col_decim)",$dbh,$opt_loop_count);
 
172
 
 
173
test_command("create_idx_hundred_code_h",
 
174
             "time for create_idx_hundred_code_h",
 
175
             "create index hundred_code_h on hundred (col_code)",$dbh,$opt_loop_count);
 
176
 
 
177
test_command("create_idx_tenpct_name_h",
 
178
             "time for create_idx_tenpct_name_h",
 
179
             "create index tenpct_name_h on tenpct (col_name)",$dbh,$opt_loop_count);
 
180
 
 
181
test_command("create_idx_updates_code_h",
 
182
             "time for create_idx_updates_code_h",
 
183
             "create index updates_code_h on updates (col_code)",$dbh,$opt_loop_count);
 
184
 
 
185
test_command("create_idx_tenpct_code_h",
 
186
             "time for create_idx_tenpct_code_h",
 
187
             "create index tenpct_code_h on tenpct (col_code)",$dbh,$opt_loop_count);
 
188
 
 
189
test_command("create_idx_updates_double_bt",
 
190
             "time for create_idx_updates_double_bt",
 
191
             "create index updates_double_bt on updates (col_double)",$dbh,$opt_loop_count);
 
192
 
 
193
test_command("create_idx_hundred_foreign",
 
194
             "time for create_idx_hundred_foreign",
 
195
             "alter table hundred add constraint fk_hundred_updates foreign key (col_signed) 
 
196
                                      references updates (col_key)",$dbh,$opt_loop_count);
 
197
 
 
198
test_query("sel_1_cl",
 
199
           "Time to sel_1_cl",
 
200
           "select col_key, col_int, col_signed, col_code, col_double, col_name 
 
201
            from updates where col_key = 1000",$dbh,$opt_loop_count);
 
202
 
 
203
test_query("join_3_cl",
 
204
           "Time to join_3_cl",
 
205
           "select uniques.col_signed, uniques.col_date, 
 
206
                   hundred.col_signed, hundred.col_date, 
 
207
                   tenpct.col_signed, tenpct.col_date 
 
208
            from uniques, hundred, tenpct 
 
209
            where uniques.col_key = hundred.col_key 
 
210
                  and uniques.col_key = tenpct.col_key 
 
211
                  and uniques.col_key = 1000",$dbh,$opt_loop_count);
 
212
 
 
213
test_query("sel_100_ncl",
 
214
           "Time to sel_100_ncl",
 
215
           "select col_key, col_int, col_signed, col_code,col_double, col_name
 
216
            from updates where col_int <= 100",$dbh,$opt_loop_count);
 
217
 
 
218
test_query("table_scan",
 
219
           "Time to table_scan",
 
220
           "select * from uniques where col_int = 1",$dbh,$opt_loop_count);
 
221
 
 
222
test_query("agg_func",
 
223
           "Time for agg_func",
 
224
           "select min(col_key) from hundred group by col_name",$dbh,$opt_loop_count);
 
225
 
 
226
test_query("agg_scal",
 
227
           "Time for agg_scal",
 
228
           "select min(col_key) from uniques",$dbh,$opt_loop_count);
 
229
 
 
230
test_query("sel_100_cl",
 
231
          "Time for sel_100_cl",
 
232
          "select col_key, col_int, col_signed, col_code, 
 
233
                  col_double, col_name 
 
234
           from updates where col_key <= 100",$dbh,$opt_loop_count);
 
235
 
 
236
test_query("join_3_ncl",
 
237
           "Time for join_3_ncl",
 
238
           "select uniques.col_signed, uniques.col_date, 
 
239
                   hundred.col_signed, hundred.col_date, 
 
240
                   tenpct.col_signed, tenpct.col_date 
 
241
            from uniques, hundred, tenpct 
 
242
            where uniques.col_code = hundred.col_code 
 
243
                  and uniques.col_code = tenpct.col_code 
 
244
                  and uniques.col_code = 'BENCHMARKS'",$dbh,$opt_loop_count);
 
245
 
 
246
test_query("sel_10pct_ncl",
 
247
           "Time for sel_10pct_ncl",
 
248
           "select col_key, col_int, col_signed, col_code, 
 
249
                   col_double, col_name 
 
250
            from tenpct 
 
251
            where col_name = 'THE+ASAP+BENCHMARKS+'",$dbh,$opt_loop_count);
 
252
 
 
253
if ($limits->{'subqueries'}){
 
254
  test_query("agg_simple_report",
 
255
             "Time for agg_simple_report",
 
256
             "select avg(updates.col_decim) 
 
257
              from updates 
 
258
              where updates.col_key in 
 
259
                        (select updates.col_key 
 
260
                         from updates, hundred 
 
261
                         where hundred.col_key = updates.col_key 
 
262
                               and updates.col_decim > 980000000)",$dbh,$opt_loop_count);
 
263
}else{
 
264
 print "agg_simple_report - Failed\n\n";
 
265
}
 
266
 
 
267
test_query("agg_info_retrieval",
 
268
           "Time for agg_info_retrieval",
 
269
           "select count(col_key) 
 
270
            from tenpct 
 
271
            where col_name = 'THE+ASAP+BENCHMARKS' 
 
272
                  and col_int <= 100000000 
 
273
                  and col_signed between 1 and 99999999 
 
274
                  and not (col_float between -450000000 and 450000000) 
 
275
                  and col_double > 600000000 
 
276
                  and col_decim < -600000000",$dbh,$opt_loop_count);
 
277
 
 
278
if ($limits->{'views'}){
 
279
  test_query("agg_create_view",
 
280
             "Time for agg_create_view",
 
281
             "create view 
 
282
                reportview(col_key,col_signed,col_date,col_decim, 
 
283
                                col_name,col_code,col_int) as 
 
284
                           select updates.col_key, updates.col_signed, 
 
285
                           updates.col_date, updates.col_decim, 
 
286
                           hundred.col_name, hundred.col_code, 
 
287
                           hundred.col_int 
 
288
                           from updates, hundred 
 
289
                           where updates.col_key = hundred.col_key",$dbh,$opt_loop_count);
 
290
 
 
291
  test_query("agg_subtotal_report",
 
292
             "Time for agg_subtotal_report",
 
293
             "select avg(col_signed), min(col_signed), max(col_signed), 
 
294
                     max(col_date), min(col_date), 
 
295
                     count(distinct col_name), count(col_name), 
 
296
                     col_code, col_int 
 
297
              from reportview 
 
298
              where col_decim >980000000 
 
299
              group by col_code, col_int",$dbh,$opt_loop_count);
 
300
 
 
301
 
 
302
  test_query("agg_total_report",
 
303
             "Time for agg_total_report",
 
304
             "select avg(col_signed), min(col_signed), max(col_signed), 
 
305
                     max(col_date), min(col_date), 
 
306
                     count(distinct col_name), count(col_name), 
 
307
                     count(col_code), count(col_int) 
 
308
              from reportview 
 
309
              where col_decim >980000000",$dbh,$opt_loop_count);
 
310
}else{
 
311
  print "agg_create_view - Failed\n\n";
 
312
  print "agg_subtotal_report - Failed\n\n";
 
313
  print "agg_total_report - Failed\n\n";
 
314
}
 
315
 
 
316
#fix from here
 
317
test_query("join_2_cl",
 
318
           "Time for join_2_cl",
 
319
           "select uniques.col_signed, uniques.col_name, 
 
320
                    hundred.col_signed, hundred.col_name 
 
321
             from uniques, hundred 
 
322
             where uniques.col_key = hundred.col_key 
 
323
              and uniques.col_key =1000"
 
324
           ,$dbh,$opt_loop_count);
 
325
 
 
326
test_query("join_2",
 
327
           "Time for join_2",
 
328
           "select uniques.col_signed, uniques.col_name, 
 
329
                     hundred.col_signed, hundred.col_name 
 
330
                from uniques, hundred 
 
331
               where uniques.col_address = hundred.col_address 
 
332
                 and uniques.col_address = 'SILICON VALLEY'"
 
333
           ,$dbh,$opt_loop_count);
 
334
 
 
335
test_query("sel_variable_select_low",
 
336
           "Time for sel_variable_select_low",
 
337
           "select col_key, col_int, col_signed, col_code, 
 
338
                    col_double, col_name 
 
339
                    from tenpct 
 
340
                    where col_signed < -500000000"
 
341
           ,$dbh,$opt_loop_count);
 
342
 
 
343
test_query("sel_variable_select_high",
 
344
           "Time for sel_variable_select_high",
 
345
           "select col_key, col_int, col_signed, col_code,
 
346
                    col_double, col_name
 
347
                    from tenpct
 
348
                    where col_signed < -250000000"
 
349
           ,$dbh,$opt_loop_count);
 
350
 
 
351
test_query("join_4_cl",
 
352
           "Time for join_4_cl",
 
353
           "select uniques.col_date, hundred.col_date, 
 
354
                    tenpct.col_date, updates.col_date 
 
355
             from uniques, hundred, tenpct, updates 
 
356
             where uniques.col_key = hundred.col_key 
 
357
               and uniques.col_key = tenpct.col_key 
 
358
               and uniques.col_key = updates.col_key 
 
359
               and uniques.col_key = 1000"
 
360
           ,$dbh,$opt_loop_count);
 
361
 
 
362
test_query("proj_100",
 
363
           "Time for proj_100",
 
364
           "select distinct col_address, col_signed from hundred"
 
365
           ,$dbh,$opt_loop_count);
 
366
 
 
367
test_query("join_4_ncl",
 
368
           "Time for join_4_ncl",
 
369
           "select uniques.col_date, hundred.col_date, 
 
370
                        tenpct.col_date, updates.col_date 
 
371
                from uniques, hundred, tenpct, updates 
 
372
                where uniques.col_code = hundred.col_code 
 
373
                    and uniques.col_code = tenpct.col_code 
 
374
                    and uniques.col_code = updates.col_code 
 
375
                    and uniques.col_code = 'BENCHMARKS'"
 
376
           ,$dbh,$opt_loop_count);
 
377
 
 
378
test_query("proj_10pct",
 
379
           "Time for proj_10pct",
 
380
           "select distinct col_signed from tenpct"
 
381
           ,$dbh,$opt_loop_count);
 
382
 
 
383
test_query("sel_1_ncl",
 
384
           "Time for sel_1_ncl",
 
385
           "select col_key, col_int, col_signed, col_code, 
 
386
                    col_double, col_name 
 
387
                    from updates where col_code = 'BENCHMARKS'"
 
388
           ,$dbh,$opt_loop_count);
 
389
 
 
390
test_query("join_2_ncl",
 
391
           "Time for join_2_ncl",
 
392
           "select uniques.col_signed, uniques.col_name, 
 
393
                         hundred.col_signed, hundred.col_name 
 
394
                    from uniques, hundred 
 
395
                    where uniques.col_code = hundred.col_code 
 
396
                    and uniques.col_code = 'BENCHMARKS'"
 
397
           ,$dbh,$opt_loop_count);
 
398
 
 
399
if ($limits->{'foreign_key'}){ 
 
400
  do_many($dbh,$server->create("integrity_temp",\@fields,[]));
 
401
 
 
402
  test_query("integrity_test_1",
 
403
             "Time for integrity_test",
 
404
             "insert into integrity_temp select * 
 
405
              from hundred where col_int=0",$dbh,$opt_loop_count);
 
406
 
 
407
  test_query("integrity_test_2",
 
408
             "Time for integrity_test",
 
409
             "update hundred set col_signed = '-500000000' 
 
410
              where col_int = 0",$dbh,$opt_loop_count);
 
411
 
 
412
  test_query("integrity_test_3",
 
413
             "Time for integrity_test",
 
414
             "update hundred set col_signed = '-500000000' 
 
415
              where col_int = 0",$dbh,$opt_loop_count);
 
416
 
 
417
 
 
418
}else{
 
419
        print "integrity_test  - Failed\n\n";
 
420
}
 
421
 
 
422
push @drop_seq_command,$server->drop_index("updates","updates_int_bt");
 
423
push @drop_seq_command,$server->drop_index("updates","updates_double_bt");
 
424
push @drop_seq_command,$server->drop_index("updates","updates_decim_bt");
 
425
push @drop_seq_command,$server->drop_index("updates","updates_code_h");
 
426
 
 
427
test_many_command("Drop updates keys",
 
428
           "Time for drop_updates_keys",
 
429
           \@drop_seq_command,$dbh,$opt_loop_count);
 
430
 
 
431
do_many($dbh,$server->create("saveupdates",\@fields,[]));
 
432
                
 
433
test_command("bulk_save",
 
434
           "Time for bulk_save",
 
435
           "insert into saveupdates select * 
 
436
                    from updates where col_key between 5000 and 5999"
 
437
           ,$dbh,$opt_loop_count);
 
438
 
 
439
test_command("bulk_modify",
 
440
           "Time for bulk_modify",
 
441
           "update updates 
 
442
                    set col_key = col_key - 100000 
 
443
                    where col_key between 5000 and 5999"
 
444
           ,$dbh,$opt_loop_count);
 
445
 
 
446
safe_command("upd_append_duplicate",
 
447
           "Time for upd_append_duplicate",
 
448
           "insert into updates  
 
449
                 values (6000, 0, 60000, 39997.90, 
 
450
                          50005.00, 50005.00, 
 
451
                          '11/10/1985', 'CONTROLLER', 
 
452
                          'ALICE IN WONDERLAND', 
 
453
                          'UNIVERSITY OF ILLINOIS AT CHICAGO')"
 
454
           ,$dbh,$opt_loop_count);
 
455
 
 
456
test_command("upd_remove_duplicate",
 
457
           "Time for upd_remove_duplicate",
 
458
           "delete from updates where col_key = 6000 and col_int = 0"
 
459
           ,$dbh,$opt_loop_count);
 
460
 
 
461
test_command("upd_app_t_mid",
 
462
           "Time for upd_app_t_mid",
 
463
           "insert into updates 
 
464
              values (5005, 5005, 50005, 50005.00, 50005.00, 
 
465
                      50005.00, '1/1/1988', 'CONTROLLER', 
 
466
                      'ALICE IN WONDERLAND', 
 
467
                      'UNIVERSITY OF ILLINOIS AT CHICAGO')"
 
468
           ,$dbh,$opt_loop_count);
 
469
 
 
470
test_command("upd_mod_t_mid",
 
471
           "Time for upd_mod_t_mid",
 
472
           "update updates set col_key = '-5000' 
 
473
                where col_key = 5005"
 
474
           ,$dbh,$opt_loop_count);
 
475
 
 
476
test_command("upd_del_t_mid",
 
477
           "Time for upd_del_t_mid",
 
478
           "delete from updates 
 
479
               where (col_key='5005') or (col_key='-5000')"
 
480
           ,$dbh,$opt_loop_count);
 
481
 
 
482
test_command("upd_app_t_end",
 
483
           "Time for upd_app_t_end",
 
484
           "delete from updates 
 
485
               where (col_key='5005') or (col_key='-5000')"
 
486
           ,$dbh,$opt_loop_count);
 
487
 
 
488
test_command("upd_mod_t_end",
 
489
           "Time for upd_mod_t_end",
 
490
           "update updates 
 
491
                set col_key = -1000 
 
492
                where col_key = 1000000001"
 
493
           ,$dbh,$opt_loop_count);
 
494
 
 
495
test_command("upd_del_t_end",
 
496
           "Time for upd_del_t_end",
 
497
           "delete from updates where col_key = -1000"
 
498
           ,$dbh,$opt_loop_count);
 
499
 
 
500
test_command("create_idx_updates_code_h",
 
501
             "time for create_idx_updates_code_h",
 
502
             "create index updates_code_h on updates (col_code)",
 
503
             $dbh,$opt_loop_count);
 
504
 
 
505
test_command("upd_app_t_mid",
 
506
           "Time for upd_app_t_mid",
 
507
           "insert into updates 
 
508
              values (5005, 5005, 50005, 50005.00, 50005.00, 
 
509
                      50005.00, '1/1/1988', 'CONTROLLER', 
 
510
                      'ALICE IN WONDERLAND', 
 
511
                      'UNIVERSITY OF ILLINOIS AT CHICAGO')"
 
512
           ,$dbh,$opt_loop_count);
 
513
 
 
514
test_command("upd_mod_t_cod",
 
515
           "Time for upd_mod_t_cod",
 
516
           "update updates 
 
517
                set col_code = 'SQL+GROUPS' 
 
518
                where col_key = 5005"
 
519
           ,$dbh,$opt_loop_count);
 
520
 
 
521
test_command("upd_del_t_mid",
 
522
           "Time for upd_del_t_mid",
 
523
           "delete from updates 
 
524
               where (col_key='5005') or (col_key='-5000')"
 
525
           ,$dbh,$opt_loop_count);
 
526
 
 
527
test_command("create_idx_updates_int_bt",
 
528
             "time for create_idx_updates_int_bt",
 
529
             "create index updates_int_bt on updates (col_int)",
 
530
             $dbh,$opt_loop_count);
 
531
 
 
532
test_command("upd_app_t_mid",
 
533
           "Time for upd_app_t_mid",
 
534
           "insert into updates 
 
535
              values (5005, 5005, 50005, 50005.00, 50005.00, 
 
536
                      50005.00, '1/1/1988', 'CONTROLLER', 
 
537
                      'ALICE IN WONDERLAND', 
 
538
                      'UNIVERSITY OF ILLINOIS AT CHICAGO')"
 
539
           ,$dbh,$opt_loop_count);
 
540
 
 
541
test_command("upd_mod_t_int",
 
542
           "Time for upd_mod_t_int",
 
543
           "update updates set col_int = 50015 where col_key = 5005"
 
544
           ,$dbh,$opt_loop_count);
 
545
 
 
546
test_command("upd_del_t_mid",
 
547
           "Time for upd_del_t_mid",
 
548
           "delete from updates 
 
549
               where (col_key='5005') or (col_key='-5000')"
 
550
           ,$dbh,$opt_loop_count);
 
551
 
 
552
test_command("bulk_append",
 
553
           "Time for bulk_append",
 
554
           "insert into updates select * from saveupdates"
 
555
           ,$dbh,$opt_loop_count);
 
556
 
 
557
test_command("bulk_delete",
 
558
           "Time for bulk_delete",
 
559
           "delete from updates where col_key < 0"
 
560
           ,$dbh,$opt_loop_count);
 
561
 
 
562
################################ END ###################################
 
563
####
 
564
#### End of the test...Finally print time used to execute the
 
565
#### whole test.
 
566
 
 
567
$dbh->disconnect;
 
568
 
 
569
end_benchmark($start_time);
 
570
 
 
571
############################ HELP FUNCTIONS ##############################
 
572
 
 
573
sub test_query
 
574
{
 
575
  my($test_text,$result_text,$query,$dbh,$count)=@_;
 
576
  my($i,$loop_time,$end_time);
 
577
 
 
578
  print $test_text . "\n";
 
579
  $loop_time=new Benchmark;
 
580
  for ($i=0 ; $i < $count ; $i++)
 
581
  {
 
582
    defined(fetch_all_rows($dbh,$query)) or warn $DBI::errstr;
 
583
  }
 
584
  $end_time=new Benchmark;
 
585
  print $result_text . "($count): " .
 
586
  timestr(timediff($end_time, $loop_time),"all") . "\n\n";
 
587
}
 
588
 
 
589
 
 
590
sub test_command
 
591
{
 
592
  my($test_text,$result_text,$query,$dbh,$count)=@_;
 
593
  my($i,$loop_time,$end_time);
 
594
 
 
595
  print $test_text . "\n";
 
596
  $loop_time=new Benchmark;
 
597
  for ($i=0 ; $i < $count ; $i++)
 
598
  {
 
599
    $dbh->do($query) or die $DBI::errstr;
 
600
  }
 
601
  $end_time=new Benchmark;
 
602
  print $result_text . "($count): " .
 
603
  timestr(timediff($end_time, $loop_time),"all") . "\n\n";
 
604
}
 
605
 
 
606
sub safe_command
 
607
{
 
608
  my($test_text,$result_text,$query,$dbh,$count)=@_;
 
609
  my($i,$loop_time,$end_time);
 
610
 
 
611
  print $test_text . "\n";
 
612
  $loop_time=new Benchmark;
 
613
  for ($i=0 ; $i < $count ; $i++)
 
614
  {
 
615
    safe_do_many($dbh,$query); 
 
616
  }
 
617
  $end_time=new Benchmark;
 
618
  print $result_text . "($count): " .
 
619
  timestr(timediff($end_time, $loop_time),"all") . "\n\n";
 
620
}
 
621
 
 
622
sub test_many_command
 
623
{
 
624
  my($test_text,$result_text,$query,$dbh,$count)=@_;
 
625
  my($i,$loop_time,$end_time);
 
626
 
 
627
  $loop_time=new Benchmark;
 
628
  for ($i=0 ; $i < $count ; $i++)
 
629
  {
 
630
    safe_do_many($dbh, @$query);
 
631
  }
 
632
  $end_time=new Benchmark;
 
633
  print $result_text . "($count): " .
 
634
  timestr(timediff($end_time, $loop_time),"all") . "\n\n";
 
635
}
 
636
 
 
637