/[pgestraier]/trunk/misc/bench.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/misc/bench.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (hide annotations)
Sun May 29 19:32:28 2005 UTC (19 years ago) by dpavlin
File MIME type: text/plain
File size: 1644 byte(s)
rewrite benchmark to use just new function, add bits of documentation

1 dpavlin 25 #!/usr/bin/perl -w
2    
3     use strict;
4    
5     use DBD::Pg;
6     use Benchmark qw(:all);
7    
8     my $connect = "DBI:Pg:dbname=test";
9     my $index = "/home/dpavlin/pgestraier/data/casket";
10    
11     my $dbh = DBI->connect($connect,"","") || die $DBI::errstr;
12    
13    
14     sub search {
15 dpavlin 26 my $def = pop;
16 dpavlin 25
17 dpavlin 26 my $sth = $dbh->prepare("select * from pgest('$index',?,?,?,?,?) as ($def)") || die $dbh->errstr();
18 dpavlin 25 $sth->execute(@_) || die $sth->errstr();
19    
20     my @arr;
21     while (my $row = $sth->fetchrow_hashref() ) {
22     push @arr, $row;
23     }
24     }
25    
26     timethese( 1000, {
27 dpavlin 26 '0_seedcache' => sub {
28     search("blade runner", undef, undef, undef, "{'\@id'}", 'id text');
29 dpavlin 25 },
30 dpavlin 26 '1_attr_1' => sub {
31     search("blade runner", undef, undef, undef, "{'\@id'}", 'id text');
32 dpavlin 25 },
33 dpavlin 26 '2_attr_2' => sub {
34     search("blade runner", undef, undef, undef, "{'\@id',\@title'}",'id text, title text');
35 dpavlin 25 },
36 dpavlin 26 '3_attr_3' => sub {
37     search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size'}",'id text, title text, size text');
38 dpavlin 25 },
39 dpavlin 26 '4_attr_4' => sub {
40     search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size','quote'}",'id text, title text, size text, quote text');
41 dpavlin 25 },
42 dpavlin 26 '5_attr_5' => sub {
43     search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size','quote','year'}",'id text, title text, size text, quote text, year text');
44 dpavlin 25 },
45 dpavlin 26 '5_attr_6' => sub {
46     search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size','quote','year',\@uri'}",'id text, title text, size text, quote text, year text, uri text');
47     },
48     '5_attr_6same' => sub {
49     search("blade runner", undef, undef, undef, "{'\@id',\@id','\@id','\@id','\@id',\@id'}",'id1 text, id2 text, id3 text, id4 text, id5 text, id6 text');
50     },
51 dpavlin 25 });

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26