File Coverage

lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Timer.pm
Criterion Covered Total %
statement 36 52 69.2
branch 0 4 0.0
condition n/a
subroutine 12 14 85.7
pod n/a
total 48 70 68.5


line stmt bran cond sub pod time code
1             # -*- coding: utf-8 -*-
2             # Copyright (C) 2011-2012, 2014-2015 Rocky Bernstein <rocky@cpan.org>
3 12     12   110 use warnings; no warnings 'redefine'; no warnings 'once';
  12     12   39  
  12     12   517  
  12     2   86  
  12     2   38  
  12     2   400  
  12         69  
  12         34  
  12         320  
  2         22  
  2         6  
  2         82  
  2         14  
  2         9  
  2         85  
  2         13  
  2         6  
  2         74  
4 12     12   74 use rlib '../../../../..';
  12     2   33  
  12         344  
  2         14  
  2         7  
  2         15  
5              
6             package Devel::Trepan::CmdProcessor::Command::Set::Timer;
7              
8 12     12   5259 use Devel::Trepan::CmdProcessor::Command::Subcmd::Core;
  12     2   38  
  12         515  
  2         1113  
  2         7  
  2         112  
9              
10             @ISA = qw(Devel::Trepan::CmdProcessor::Command::SetBoolSubcmd);
11             # Values inherited from parent
12 12     12   85 use vars @Devel::Trepan::CmdProcessor::Command::Subcmd::SUBCMD_VARS;
  12     2   37  
  12         4812  
  2         19  
  2         7  
  2         853  
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 0     0     my ($self, $args) = @_;
  0     0      
59 0           $self->SUPER::run($args);
  0            
60 0           my $proc = $self->{proc};
  0            
61 0 0         if ( $proc->{settings}{timer} ) {
  0 0          
62             $proc->{cmdloop_posthooks}->insert_if_new(-1, $proc->{timer_hook}[0],
63 0           $proc->{timer_hook}[1]);
  0            
64             $proc->{cmdloop_prehooks}->insert_if_new(-1, $proc->{timer_hook}[0],
65 0           $proc->{timer_hook}[1]);
  0            
66             } else {
67 0           $proc->{cmdloop_posthooks}->delete_by_name('timer');
  0            
68 0           $proc->{cmdloop_posthooks}->delete_by_name('timer');
  0            
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;