/[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

Contents of /trunk/misc/bench.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (show annotations)
Fri May 27 21:06:01 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1122 byte(s)
removed obsolete implementeation without attribute specification which was
also slower according to benchmarks.

1 #!/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 my $sth_old = $dbh->prepare(qq`
14 select * from pgest('$index',?,?,?,?)
15 `) || die $dbh->errstr();
16
17 my $sth_new = $dbh->prepare(qq`
18 select * from pgest('$index',?,?,?,?,?) as (id text)
19 `) || die $dbh->errstr();
20
21 sub search {
22 my $sth = shift;
23
24 $sth->execute(@_) || die $sth->errstr();
25
26 my @arr;
27 while (my $row = $sth->fetchrow_hashref() ) {
28 push @arr, $row;
29 }
30 }
31
32 timethese( 1000, {
33 '0_old' => sub {
34 search($sth_old, "blade runner", undef, undef, undef);
35 },
36 '1_new' => sub {
37 search($sth_new, "blade runner", undef, undef, undef, "{'\@id'}");
38 },
39 '2_old' => sub {
40 search($sth_old, "blade runner", undef, undef, undef);
41 },
42 '3_new' => sub {
43 search($sth_new, "blade runner", undef, undef, undef, "{'\@id'}");
44 },
45 '4_old' => sub {
46 search($sth_old, "blade runner", undef, undef, undef);
47 },
48 '5_new' => sub {
49 search($sth_new, "blade runner", undef, undef, undef, "{'\@id'}");
50 },
51 });

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26