X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FBenchmarks%2Fbenchmark_join_optimizer.pl;fp=examples%2FBenchmarks%2Fbenchmark_join_optimizer.pl;h=68b4a5065c0d182c0f830dd943333c7e60ee5768;hb=df9da3541a831d9333c9eccb058e40e905a4b3c6;hp=0000000000000000000000000000000000000000;hpb=e400c82dcda5d575e6d745f23a1be5e8d1c2af14;p=dbsrgits%2FDBIx-Class.git diff --git a/examples/Benchmarks/benchmark_join_optimizer.pl b/examples/Benchmarks/benchmark_join_optimizer.pl new file mode 100755 index 0000000..68b4a50 --- /dev/null +++ b/examples/Benchmarks/benchmark_join_optimizer.pl @@ -0,0 +1,48 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Time::HiRes qw(gettimeofday tv_interval); +use Digest::SHA 'sha1_hex'; + +use lib 't/lib'; +BEGIN { $ENV{DBICTEST_ANFANG_DEFANG} = 1 }; +use DBICTest; + +my $schema = DBICTest->init_schema( + quote_names => 1, + cursor_class => 'DBIx::Class::Cursor::Cached' +); + +use Cache::FileCache; +my $c = Cache::FileCache->new({ namespace => 'SchemaClass' }); + +for my $i (1..9) { + + my $t0 = [gettimeofday]; + + # getting a fresh rs makes sure we do not cache anything + my $rs = $schema->resultset("Artist")->search({},{ + cache_object => $c, + cache_for => 999999999999, + prefetch => { + cds => [ + ( { tracks => { cd_single => { artist => { cds => { tracks => 'cd_single' } } } } } ) x 50, + ], + }, + rows => 2, + }); + + my $q = ${$rs->as_query}->[0]; + + print STDERR "@{[ length $q]} byte-long query generated (via as_query() in: ".tv_interval($t0) . " seconds (take $i)\n"; + + # stuff below can be made even faster, but another time + next; + + $t0 = [ gettimeofday ]; + + my $x = $rs->all_hri; + print STDERR "Got collapsed results (via HRI) in: ".tv_interval($t0) . " seconds (take $i)\n"; +}