increment $VERSION after 1.003029 release
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Timing.pm
CommitLineData
1716b200 1use strict;
2use warnings;
296c23ff 3package Devel::REPL::Plugin::Timing;
9d2a4940 4# ABSTRACT: Display execution times
296c23ff 5
77327851 6our $VERSION = '1.003030';
54beb05d 7
6a5409bc 8use Devel::REPL::Plugin;
296c23ff 9use Time::HiRes 'time';
aa8b7647 10use namespace::autoclean;
296c23ff 11
12around '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
301;
31
cfd1094b 32__END__
33
9d2a4940 34=pod
cfd1094b 35
e4761e81 36=head1 SYNOPSIS
37
38 # in your re.pl file:
39 use Devel::REPL;
40 my $repl = Devel::REPL->new;
41 $repl->load_plugin('Timing');
42
43 # after you run re.pl:
44 $ sum map $_*100, 1..100000;
45 Took 0.0830280780792236 seconds.
46 500005000000
47
48 $
49
30b459d4 50=head1 AUTHOR
51
52Shawn M Moore, C<< <sartak at gmail dot com> >>
53
cfd1094b 54=cut