line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
2940
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
99
|
|
2
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
183
|
|
3
|
|
|
|
|
|
|
package Devel::REPL::Plugin::Timing; |
4
|
|
|
|
|
|
|
# ABSTRACT: Display execution times |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.003027'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
15
|
use Devel::REPL::Plugin; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
22
|
|
9
|
2
|
|
|
2
|
|
10090
|
use Time::HiRes 'time'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
26
|
|
10
|
2
|
|
|
2
|
|
524
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
27
|
|
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.003027 |
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 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Shawn M Moore, C<< <sartak at gmail dot com> >> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>). |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
69
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |