t/test51-enable.p

filter: Statementstmt 96.3% 26 / 27 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 89.7% 35 / 39 CC 1 SCAR 1.2
CC
1
Cov
90%
sub8
2.0
sub1
1.0
sub2
1.0
CRAP 1.1
« t/test62-subcaller1-b.p ↑ Summary blib/lib/Devel/NYTProf/Core.pm »
1 # test using enable_profile() to write multiple profile files
2  
3 16 my $file_b = "nytprof-test51-b.out";
4 16 my $file_c = "nytprof-test51-c.out";
5 16 unlink $file_b, $file_c;
6  
7 16 ▶sub sub1 { 1 }
Subroutine sub1: called CC=1 SCAR=0.0
8 16 ▶sub sub2 { 1 }
Subroutine sub2: called CC=1 SCAR=0.0
9 16 ▶sub sub3 { 1 }
Subroutine sub3: called CC=1 SCAR=0.0
10 16 ▶sub sub4 { 1 }
Subroutine sub4: called CC=1 SCAR=0.0
11 16 ▶sub sub5 { 1 }
Subroutine sub5: called CC=1 SCAR=0.0
12 16 ▶sub sub6 { 1 }
Subroutine sub6: called CC=1 SCAR=0.0
13 16 ▶sub sub7 { 1 }
Subroutine sub7: called CC=1 SCAR=0.0
14 0 ▶sub sub8 { 1 }
Subroutine sub8: not called CC=1 SCAR=6.9
15  
16 16 sub1(); # profiled
17  
18 16 DB::disable_profile(); # also tests that sub1() call timing has completed
19  
20 16 sub2(); # not profiled
21  
22 # switch to new file and (re)enable profiling
23 # the new file includes accumulated fid and subs-called data
24 16 DB::enable_profile($file_b);
25  
26 16 sub3(); # profiled
27  
28 16 DB::finish_profile();
29 16 ▶die "$file_b should exist" unless -s $file_b;
Branch: 1 branch
BranchTrueFalseTotal
unless -s $file_b 0 16 16
30  
31 16 sub4(); # not profiled
32  
33 # enable to new file
34 16 DB::enable_profile($file_c);
35  
36 16 sub5(); # profiled but file will be overwritten by enable_profile() below
37  
38 16 DB::finish_profile();
39  
40 16 sub6(); # not profiled
41  
42 16 DB::enable_profile(); # enable to current file
43  
44 16 sub7(); # profiled
45  
46 16 DB::finish_profile();
47  
48 # This can be removed once we have a better test harness
49 16 ▶-f $_ or die "$_ should exist" for ($file_b, $file_c);
Branch: 1 branch
BranchTrueFalseTotal
-f $_ or die "$_ should exist" 32 0 32
50  
51 # TODO should test for enable/disable within subs
« t/test62-subcaller1-b.p ↑ Summary blib/lib/Devel/NYTProf/Core.pm »