keep $VERSION right in the repo
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Timing.pm
CommitLineData
1716b200 1use strict;
2use warnings;
296c23ff 3package Devel::REPL::Plugin::Timing;
4
54beb05d 5our $VERSION = '1.003027';
6
6a5409bc 7use Devel::REPL::Plugin;
296c23ff 8use Time::HiRes 'time';
aa8b7647 9use namespace::autoclean;
296c23ff 10
11around 'eval' => sub {
12 my $orig = shift;
13 my ($self, $line) = @_;
14
15 my @ret;
16 my $start = time;
17
18 if (wantarray) {
19 @ret = $self->$orig($line);
20 }
21 else {
22 $ret[0] = $self->$orig($line);
23 }
24
25 $self->print("Took " . (time - $start) . " seconds.\n");
26 return @ret;
27};
28
291;
30
cfd1094b 31__END__
32
33=head1 NAME
34
35Devel::REPL::Plugin::Timing - display execution times
36
e4761e81 37=head1 SYNOPSIS
38
39 # in your re.pl file:
40 use Devel::REPL;
41 my $repl = Devel::REPL->new;
42 $repl->load_plugin('Timing');
43
44 # after you run re.pl:
45 $ sum map $_*100, 1..100000;
46 Took 0.0830280780792236 seconds.
47 500005000000
48
49 $
50
30b459d4 51=head1 AUTHOR
52
53Shawn M Moore, C<< <sartak at gmail dot com> >>
54
cfd1094b 55=cut
56