Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / examples / Benchmarks / benchmark_join_optimizer.pl
CommitLineData
df9da354 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5
6use Time::HiRes qw(gettimeofday tv_interval);
7use Digest::SHA 'sha1_hex';
8
9use lib 't/lib';
10BEGIN { $ENV{DBICTEST_ANFANG_DEFANG} = 1 };
11use DBICTest;
12
13my $schema = DBICTest->init_schema(
14 quote_names => 1,
15 cursor_class => 'DBIx::Class::Cursor::Cached'
16);
17
18use Cache::FileCache;
19my $c = Cache::FileCache->new({ namespace => 'SchemaClass' });
20
21for my $i (1..9) {
22
23 my $t0 = [gettimeofday];
24
25 # getting a fresh rs makes sure we do not cache anything
26 my $rs = $schema->resultset("Artist")->search({},{
27 cache_object => $c,
28 cache_for => 999999999999,
29 prefetch => {
30 cds => [
31 ( { tracks => { cd_single => { artist => { cds => { tracks => 'cd_single' } } } } } ) x 50,
32 ],
33 },
34 rows => 2,
35 });
36
37 my $q = ${$rs->as_query}->[0];
38
39 print STDERR "@{[ length $q]} byte-long query generated (via as_query() in: ".tv_interval($t0) . " seconds (take $i)\n";
40
41 # stuff below can be made even faster, but another time
42 next;
43
44 $t0 = [ gettimeofday ];
45
46 my $x = $rs->all_hri;
47 print STDERR "Got collapsed results (via HRI) in: ".tv_interval($t0) . " seconds (take $i)\n";
48}