Commit | Line | Data |
df9da354 |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Time::HiRes qw(gettimeofday tv_interval); |
7 | use Digest::SHA 'sha1_hex'; |
8 | |
9 | use lib 't/lib'; |
10 | BEGIN { $ENV{DBICTEST_ANFANG_DEFANG} = 1 }; |
11 | use DBICTest; |
12 | |
13 | my $schema = DBICTest->init_schema( |
14 | quote_names => 1, |
15 | cursor_class => 'DBIx::Class::Cursor::Cached' |
16 | ); |
17 | |
18 | use Cache::FileCache; |
19 | my $c = Cache::FileCache->new({ namespace => 'SchemaClass' }); |
20 | |
21 | for 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 | } |