| 1 | # This code is part of Perl distribution Log-Report version 1.46. | ||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||
| 3 | # For contributors see file ChangeLog. | ||
| 4 | |||
| 5 | # This software is copyright (c) 2007-2026 by Mark Overmeer. | ||
| 6 | |||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||
| 10 | |||
| 11 | |||
| 12 | package Log::Report::DBIC::Profiler;{ | ||
| 13 | our $VERSION = '1.46'; | ||
| 14 | } | ||
| 15 | |||
| 16 | use base 'DBIx::Class::Storage::Statistics'; | ||
| 17 | |||
| 18 | use strict; | ||
| 19 | use warnings; | ||
| 20 | |||
| 21 | use Log::Report 'log-report', import => 'trace'; | ||
| 22 | use Time::HiRes qw/time/; | ||
| 23 | |||
| 24 | #-------------------- | ||
| 25 | |||
| 26 | my $start; | ||
| 27 | |||
| 28 | sub print($) { trace $_[1] } | ||
| 29 | |||
| 30 | sub query_start(@) | ||
| 31 | { my $self = shift; | ||
| 32 | $self->SUPER::query_start(@_); | ||
| 33 | $start = time; | ||
| 34 | } | ||
| 35 | |||
| 36 | sub query_end(@) | ||
| 37 | { my $self = shift; | ||
| 38 | $self->SUPER::query_end(@_); | ||
| 39 | trace sprintf "execution took %0.4f seconds elapse", time-$start; | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; |