File: test51-enable.p

package info (click to toggle)
libdevel-nytprof-perl 6.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,552 kB
  • sloc: perl: 5,616; javascript: 4,033; ansic: 107; makefile: 23
file content (51 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# test using enable_profile() to write multiple profile files

my $file_b = "nytprof-test51-b.out";
my $file_c = "nytprof-test51-c.out";
unlink $file_b, $file_c;

sub sub1 { 1 }
sub sub2 { 1 }
sub sub3 { 1 }
sub sub4 { 1 }
sub sub5 { 1 }
sub sub6 { 1 }
sub sub7 { 1 }
sub sub8 { 1 }

sub1(); # profiled

DB::disable_profile(); # also tests that sub1() call timing has completed

sub2(); # not profiled

# switch to new file and (re)enable profiling
# the new file includes accumulated fid and subs-called data
DB::enable_profile($file_b);

sub3(); # profiled

DB::finish_profile();
die "$file_b should exist" unless -s $file_b;

sub4(); # not profiled

# enable to new file
DB::enable_profile($file_c);

sub5(); # profiled but file will be overwritten by enable_profile() below

DB::finish_profile();

sub6(); # not profiled

DB::enable_profile(); # enable to current file

sub7(); # profiled

DB::finish_profile();

# This can be removed once we have a better test harness
-f $_ or die "$_ should exist" for ($file_b, $file_c);

# TODO should test for enable/disable within subs