/[Search-Estraier]/trunk/scripts/bench_search.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/scripts/bench_search.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 127 - (show annotations)
Sat May 6 22:09:01 2006 UTC (17 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1007 byte(s)
script to benchmark old and new implementation of search
1 #!/usr/bin/perl -w
2
3 # bench_search.pl - benchmark new and old implementation of search
4 #
5 # 05/06/2006 11:38:32 PM CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use strict;
8 use blib;
9 use Benchmark qw/:all :hireswallclock/;
10 use Search::Estraier;
11
12 my $count = 100;
13 my $url = 'http://localhost:1978/node/cpan';
14
15 # create and configure node
16 my $node = new Search::Estraier::Node(
17 url => $url,
18 user => 'admin',
19 passwd => 'admin',
20 croak_on_error => 1,
21 );
22
23 # create condition
24 my $cond = new Search::Estraier::Condition;
25
26 my $code_ref;
27 my $q = '';
28 my $l = 0;
29
30 foreach my $w (qw/full text search/) {
31 $q .= " $w";
32 $l++;
33
34 # set search phrase
35 $cond->set_phrase( $q );
36
37 $code_ref->{'old_' . $l} = sub {
38 my $nres = $node->search($cond, 0) or
39 die "error: ", $node->status,"\n";
40 };
41
42 $code_ref->{'new_' . $l} = sub {
43 my $nres = $node->search_new($cond, 0) or
44 die "error: ", $node->status,"\n";
45 };
46 }
47
48 use Data::Dumper;
49 print Dumper($code_ref);
50
51 timethese($count, $code_ref);
52 cmpthese($count, $code_ref);
53

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26