blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Timer.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 54 CC 2 SCAR 10.6
CC
2
Cov
0%
run
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.9
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2012, 2014-2015 Rocky Bernstein <rocky@cpan.org>
3 use warnings; no warnings 'redefine'; no warnings 'once';
4 use rlib '../../../../..';
5  
6 package Devel::Trepan::CmdProcessor::Command::Set::Timer;
7  
8 use Devel::Trepan::CmdProcessor::Command::Subcmd::Core;
9  
10 @ISA = qw(Devel::Trepan::CmdProcessor::Command::SetBoolSubcmd);
11 # Values inherited from parent
12 use vars @Devel::Trepan::CmdProcessor::Command::Subcmd::SUBCMD_VARS;
13  
14 our $IN_LIST = 1;
15 =pod
16  
17 =head2 Synopsis:
18  
19 =cut
20  
21 our $HELP = <<"HELP";
22 =pod
23  
24 B<set timer> [B<on>|B<off>]
25  
26 Tracks and shows elapsed time between debugger events. If "on" or
27 "off" is not given, "on" is assumed.
28  
29 Since debugger overhead can be large depending on what you are doing,
30 there are many ways to customize the debugger to take less time (and
31 do less).
32  
33 Stepping is slow, running to a breakpoint without stepping is
34 relatively fast compared to previous versions of the debugger and
35 compared to stepping.
36  
37 Stopping at fewer events can also speed things up. Trace event
38 buffering slows things down.
39  
40 Buy turning this setting on, you may be able to get a feel for what
41 how expensive the various settings.
42  
43 =head2 See also:
44  
45 L<C<set events>|Devel::Trepan::CmdProcessor::Command::Set::Events>,
46 L<C<set trace buffer>|Devel::Trepan::CmdProcessor::Command::Set::Trace::Buffer>,
47 L<C<step>|Devel::Trepan::CmdProcessor::Command::Step>, and
48 L<C<break>|Devel::Trepan::CmdProcessor::Command::Break>,
49  
50 =cut
51 HELP
52  
53 our $SHORT_HELP = "Set to show elapsed time between debugger events";
54 our $MIN_ABBREV = length('ti');
55  
56 sub run($$)
57 {
58 my ($self, $args) = @_;
59 $self->SUPER::run($args);
60 my $proc = $self->{proc};
61 if ( $proc->{settings}{timer} ) {
62 $proc->{cmdloop_posthooks}->insert_if_new(-1, $proc->{timer_hook}[0],
63 $proc->{timer_hook}[1]);
64 $proc->{cmdloop_prehooks}->insert_if_new(-1, $proc->{timer_hook}[0],
65 $proc->{timer_hook}[1]);
66 } else {
67 $proc->{cmdloop_posthooks}->delete_by_name('timer');
68 $proc->{cmdloop_posthooks}->delete_by_name('timer');
69 }
70 }
71  
72 unless (caller) {
73 # Demo it.
74 # FIXME: DRY with other subcommand manager demo code.
75 require Devel::Trepan::CmdProcessor::Mock;
76 my ($proc, $cmd) =
77 Devel::Trepan::CmdProcessor::Mock::subcmd_setup();
78 Devel::Trepan::CmdProcessor::Mock::subcmd_demo_info($proc, $cmd);
79 $cmd->run($cmd->{prefix});
80 my @args = (@{$cmd->{prefix}}, 'off');
81 $cmd->run(\@args);
82 }
83  
84 1;