File Coverage

blib/lib/Class/ReluctantORM/Monitor/RowSize.pm
Criterion Covered Total %
statement 12 17 70.5
branch n/a
condition n/a
subroutine 4 8 50.0
pod 4 4 100.0
total 20 29 68.9


line stmt bran cond sub pod time code
1             package Class::ReluctantORM::Monitor::RowSize;
2              
3             =head1 NAME
4              
5             Class::ReluctantORM::Monitor::RowSize - Track size in bytes of each row
6              
7             =head1 SYNOPSIS
8              
9             use aliased 'Class::ReluctantORM::Monitor::RowSize';
10             my $mon = RowSize->new(highwater_count => N, fatal_threshold => X);
11             Class::ReluctantORM->install_global_monitor($mon);
12             Pirate->install_class_monitor($mon);
13              
14             # Do a query....
15             Pirate->fetch(...);
16              
17             # Read from the monitor
18             my $count = $mon->last_measured_value();
19              
20             # Reset is not useful here
21              
22             =head1 DESCRIPTION
23              
24             Tracks the size of each row returned by a query. The counter is set to the size, in bytes, of the data contained in each row. Each row individually could be a high-water mark.
25              
26             This is a Measuring Monitor.
27              
28             =cut
29              
30 1     1   5 use strict;
  1         2  
  1         30  
31 1     1   6 use warnings;
  1         2  
  1         24  
32 1     1   5 use base 'Class::ReluctantORM::Monitor::Measuring';
  1         1  
  1         70  
33 1     1   6 use Class::ReluctantORM::Utilities qw(row_size);
  1         2  
  1         214  
34              
35 0     0 1   sub permitted_events { return qw(fetch_row); }
36 0     0 1   sub default_events { return qw(fetch_row); }
37 0     0 1   sub measurement_label { return 'Data size in bytes of this row'; }
38             sub take_measurement {
39 0     0 1   my ($mon, %event) = @_;
40 0           return row_size($event{row});
41             }
42              
43             1;