/usr/share/doc/librdf-query-perl/examples/bin/graph-qeps.pl is in librdf-query-perl 2.918-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #!/usr/bin/env perl
use strict;
use warnings;
no warnings 'redefine';
use lib qw(. t lib .. ../t ../lib);
require "t/models.pl";
unless (@ARGV) {
print <<"END";
USAGE: perl $0 data.rdf [ \$MBOX_SHA ]
Benchmarks a simple 2-triple BGP execution, trying all possible query plans.
To run this benchmark with your own data, pass \$MBOX_SHA as a valid
foaf:mbox_sha1sum value that is present in data.rdf.
END
exit;
}
our $MBOX_SHA = 'f80a0f19d2a0897b89f48647b2fb5ca1f0bc1cb8';
my @files = @ARGV;
my @models = test_models( @files );
use RDF::Query;
use GraphViz;
use List::Util qw(first);
use Time::HiRes qw(tv_interval gettimeofday);
use Benchmark qw(cmpthese);
################################################################################
# Log::Log4perl::init( \q[
# log4perl.category.rdf.query.algebra = DEBUG, Screen
# log4perl.appender.Screen = Log::Log4perl::Appender::Screen
# log4perl.appender.Screen.stderr = 0
# log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
# ] );
################################################################################
my ($model) = first { $_->isa('RDF::Trine::Model') } @models;
my $query = &RDF::Query::Util::cli_make_query or die RDF::Query->error;
my $context = RDF::Query::ExecutionContext->new(
bound => {},
model => $model,
query => $query,
optimize => 1,
);
my @plans = $query->query_plan( $context );
my %plans;
foreach my $i (0 .. $#plans) {
my $name = "plan $i";
warn "$name: " . $plans[ $i ]->sse( {}, ' 'x8 ) . "\n";
my $g = new GraphViz;
my $plan = $plans[ $i ];
$plan->graph( $g );
open( my $fh, '>', "qep-${i}.png" ) or die $!;
print {$fh} $g->as_png;
close($fh);
$plans{ $name } = sub {
local($query->{plan_index}) = $i;
my $stream = $query->execute( $model );
my @res = $stream->get_all;
};
}
cmpthese( 15, \%plans );
package RDF::Query::Benchmark;
use strict;
use warnings;
use base qw(RDF::Query);
sub prune_plans {
my $self = shift;
my $context = shift;
my @plans = @_;
my $index = $self->{ plan_index };
my $plan = $plans[ $index ];
return $plan;
}
|