| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 2 |  |  | 2 |  | 2177 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 67 |  | 
| 2 | 2 |  |  | 2 |  | 6 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 131 |  | 
| 3 |  |  |  |  |  |  | package Devel::REPL::Plugin::Timing; | 
| 4 |  |  |  |  |  |  | # ABSTRACT: Display execution times | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '1.003028'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 2 |  |  | 2 |  | 10 | use Devel::REPL::Plugin; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 17 |  | 
| 9 | 2 |  |  | 2 |  | 6176 | use Time::HiRes 'time'; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 18 |  | 
| 10 | 2 |  |  | 2 |  | 314 | use namespace::autoclean; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 15 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | around 'eval' => sub { | 
| 13 |  |  |  |  |  |  | my $orig = shift; | 
| 14 |  |  |  |  |  |  | my ($self, $line) = @_; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | my @ret; | 
| 17 |  |  |  |  |  |  | my $start = time; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | if (wantarray) { | 
| 20 |  |  |  |  |  |  | @ret = $self->$orig($line); | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  | else { | 
| 23 |  |  |  |  |  |  | $ret[0] = $self->$orig($line); | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | $self->print("Took " . (time - $start) . " seconds.\n"); | 
| 27 |  |  |  |  |  |  | return @ret; | 
| 28 |  |  |  |  |  |  | }; | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | 1; | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | __END__ | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | =pod | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =encoding UTF-8 | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =head1 NAME | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Devel::REPL::Plugin::Timing - Display execution times | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head1 VERSION | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | version 1.003028 | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | # in your re.pl file: | 
| 49 |  |  |  |  |  |  | use Devel::REPL; | 
| 50 |  |  |  |  |  |  | my $repl = Devel::REPL->new; | 
| 51 |  |  |  |  |  |  | $repl->load_plugin('Timing'); | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | # after you run re.pl: | 
| 54 |  |  |  |  |  |  | $ sum map $_*100, 1..100000; | 
| 55 |  |  |  |  |  |  | Took 0.0830280780792236 seconds. | 
| 56 |  |  |  |  |  |  | 500005000000 | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | $ | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =head1 SUPPORT | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> | 
| 63 |  |  |  |  |  |  | (or L<bug-Devel-REPL@rt.cpan.org|mailto:bug-Devel-REPL@rt.cpan.org>). | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | There is also an irc channel available for users of this distribution, at | 
| 66 |  |  |  |  |  |  | L<C<#devel> on C<irc.perl.org>|irc://irc.perl.org/#devel-repl>. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 AUTHOR | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | Shawn M Moore, C<< <sartak at gmail dot com> >> | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENCE | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>). | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 77 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =cut |