Commit | Line | Data |
---|---|---|
296c23ff | 1 | package Devel::REPL::Plugin::Timing; |
2 | ||
3 | use Moose::Role; | |
4 | use Time::HiRes 'time'; | |
5 | use namespace::clean -except => [ 'meta' ]; | |
6 | ||
7 | around 'eval' => sub { | |
8 | my $orig = shift; | |
9 | my ($self, $line) = @_; | |
10 | ||
11 | my @ret; | |
12 | my $start = time; | |
13 | ||
14 | if (wantarray) { | |
15 | @ret = $self->$orig($line); | |
16 | } | |
17 | else { | |
18 | $ret[0] = $self->$orig($line); | |
19 | } | |
20 | ||
21 | $self->print("Took " . (time - $start) . " seconds.\n"); | |
22 | return @ret; | |
23 | }; | |
24 | ||
25 | 1; | |
26 |