| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
846
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
79
|
|
|
2
|
|
|
|
|
|
|
package Benchmark::Harness::TraceHighRes; |
|
3
|
1
|
|
|
1
|
|
7
|
use base qw(Benchmark::Harness::Trace); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
291
|
|
|
4
|
1
|
|
|
1
|
|
9
|
use Benchmark::Harness; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use Benchmark::Harness::Constants; |
|
|
1
|
|
|
|
|
25
|
|
|
|
1
|
|
|
|
|
124
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use vars qw($VERSION); $VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
714
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
### ########################################################################### |
|
10
|
|
|
|
|
|
|
sub Initialize { |
|
11
|
0
|
|
|
0
|
0
|
|
my $self = Benchmark::Harness::Trace::Initialize(@_); |
|
12
|
0
|
|
|
|
|
|
$self->{_startTime} = Time::HiRes::time(); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Things we get for the ProcessInfo element: |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# W32 Linux attr : meaning |
|
17
|
|
|
|
|
|
|
# X X 'm' : virtual memory size (kilobytes) |
|
18
|
|
|
|
|
|
|
# X 'r' : resident set size (kilobytes) |
|
19
|
|
|
|
|
|
|
# X 'u' : user mode time (milliseconds) |
|
20
|
|
|
|
|
|
|
# X 's' : kernel mode time (milliseconds) |
|
21
|
|
|
|
|
|
|
# X 'x' : user + kernal time |
|
22
|
|
|
|
|
|
|
# ? ? 't' : system time, since process started, from time() |
|
23
|
|
|
|
|
|
|
# X 'p' : percent cpu used since process started |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## from i686-linux-64int-ld |
|
26
|
|
|
|
|
|
|
# 'euid' => 509, |
|
27
|
|
|
|
|
|
|
# 'priority' => 0, |
|
28
|
|
|
|
|
|
|
# 'wchan' => 0, |
|
29
|
|
|
|
|
|
|
# 'cmndline' => '/usr/local/bin/perl5.8.3 test.pl ', |
|
30
|
|
|
|
|
|
|
# 'fname' => 'perl5.8.3', |
|
31
|
|
|
|
|
|
|
# 'cmajflt' => 29001, |
|
32
|
|
|
|
|
|
|
# 'state' => 'run', |
|
33
|
|
|
|
|
|
|
# 'pid' => 24077, |
|
34
|
|
|
|
|
|
|
# 'cwd' => '/goto/big/stats/lib/perl/Benchmark', |
|
35
|
|
|
|
|
|
|
# 'cminflt' => 10703, |
|
36
|
|
|
|
|
|
|
# 'exec' => '/usr/local/bin/perl5.8.3', |
|
37
|
|
|
|
|
|
|
# 'uid' => 509, |
|
38
|
|
|
|
|
|
|
# 'cstime' => 7000, |
|
39
|
|
|
|
|
|
|
# 'minflt' => 7084, |
|
40
|
|
|
|
|
|
|
# 'pctcpu' => '0.00', |
|
41
|
|
|
|
|
|
|
# 'suid' => 509, |
|
42
|
|
|
|
|
|
|
# 'utime' => 0, |
|
43
|
|
|
|
|
|
|
# 'pgrp' => 24077, |
|
44
|
|
|
|
|
|
|
# 'start' => '1116131498', |
|
45
|
|
|
|
|
|
|
# 'gid' => 509, |
|
46
|
|
|
|
|
|
|
# 'ttydev' => '/dev/pts/8', |
|
47
|
|
|
|
|
|
|
# 'fgid' => 509, |
|
48
|
|
|
|
|
|
|
# 'pctmem' => '0.00', |
|
49
|
|
|
|
|
|
|
# 'time' => 0, |
|
50
|
|
|
|
|
|
|
# 'sess' => 26032, |
|
51
|
|
|
|
|
|
|
# 'egid' => 509, |
|
52
|
|
|
|
|
|
|
# 'size' => 7208960, |
|
53
|
|
|
|
|
|
|
# 'ttynum' => 34824, |
|
54
|
|
|
|
|
|
|
# 'stime' => 0, |
|
55
|
|
|
|
|
|
|
# 'ctime' => 8000, |
|
56
|
|
|
|
|
|
|
# 'sgid' => 509, |
|
57
|
|
|
|
|
|
|
# 'flags' => 1048576, |
|
58
|
|
|
|
|
|
|
# 'cutime' => 1000, |
|
59
|
|
|
|
|
|
|
# 'majflt' => 436, |
|
60
|
|
|
|
|
|
|
# 'fuid' => 509, |
|
61
|
|
|
|
|
|
|
# 'ppid' => 26032, |
|
62
|
|
|
|
|
|
|
# 'rss' => 5177344 |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ( $^O ne 'MSWin32' ) { # Assume Linux, for now . . . |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
eval 'use Proc::ProcessTable'; |
|
67
|
0
|
0
|
|
|
|
|
die $@ if $@; |
|
68
|
0
|
|
|
|
|
|
my $procProcessTbl = new Proc::ProcessTable('cache_ttys' => 1); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
*Benchmark::Harness::Handler::TraceHighRes::reportTraceInfo = |
|
71
|
|
|
|
|
|
|
sub { |
|
72
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $processTable = $procProcessTbl->table; |
|
75
|
0
|
|
|
|
|
|
my $processIdx = $self->[Benchmark::Harness::Handler::HNDLR_PROCESSIDX]; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
my $procInfo = $processTable->[$processIdx] if defined($processIdx); |
|
78
|
|
|
|
|
|
|
# Our process idx is probably the same each time through . . . |
|
79
|
0
|
0
|
0
|
|
|
|
unless ( ref($procInfo) && ($procInfo->{pid} == $$) ) { |
|
80
|
0
|
|
|
|
|
|
my $processIdx = 0; |
|
81
|
0
|
|
|
|
|
|
for ( @$processTable ) { |
|
82
|
0
|
0
|
|
|
|
|
if ( $_->{pid} == $$ ) { |
|
83
|
0
|
|
|
|
|
|
$procInfo = $_; |
|
84
|
0
|
|
|
|
|
|
last; |
|
85
|
|
|
|
|
|
|
} else { |
|
86
|
0
|
|
|
|
|
|
$processIdx += 1; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
0
|
|
|
|
|
|
$self->[HNDLR_PROCESSIDX] = $processIdx; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# a problem with Proc::ProcessTable needs to be fixed |
|
93
|
0
|
|
|
|
|
|
my $largeError = 2147483648; |
|
94
|
0
|
|
|
|
|
|
my $mMem = $procInfo->{size}; |
|
95
|
0
|
0
|
|
|
|
|
$mMem = $largeError + ($largeError+$mMem) if ( $mMem < 0 ); |
|
96
|
0
|
|
|
|
|
|
my $rMem = $procInfo->{rss}; |
|
97
|
0
|
0
|
|
|
|
|
$rMem = $largeError + ($largeError+$rMem) if ( $rMem < 0 ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Note: we do not call direct-parent ::Trace, since we're duplicating all its attributes, anyway |
|
100
|
0
|
|
|
|
|
|
Benchmark::Harness::Handler::reportTraceInfo($self, |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
|
|
|
|
|
|
'm' => $mMem / 1024 |
|
103
|
|
|
|
|
|
|
,'p' => $procInfo->{pctcpu} |
|
104
|
|
|
|
|
|
|
,'r' => $rMem / 1024 |
|
105
|
|
|
|
|
|
|
,'s' => $procInfo->{stime} |
|
106
|
|
|
|
|
|
|
,'t' => (Time::HiRes::time() - $self->[HNDLR_HARNESS]->{_startTime}) |
|
107
|
|
|
|
|
|
|
,'u' => $procInfo->{utime} |
|
108
|
|
|
|
|
|
|
,'x' => $procInfo->{time}/1000 |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
,@_ |
|
111
|
|
|
|
|
|
|
); |
|
112
|
0
|
|
|
|
|
|
}; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
0
|
|
|
|
|
|
return $self; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
package Benchmark::Harness::Handler::TraceHighRes; |
|
119
|
1
|
|
|
1
|
|
9
|
use base qw(Benchmark::Harness::Handler::Trace); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
666
|
|
|
120
|
1
|
|
|
1
|
|
8
|
use Benchmark::Harness::Constants; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
86
|
|
|
121
|
1
|
|
|
1
|
|
549637
|
use Time::HiRes; |
|
|
1
|
|
|
|
|
2385
|
|
|
|
1
|
|
|
|
|
12
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=pod |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 Benchmark::Harness::TraceHighRes |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 SYNOPSIS |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
(stay tuned . . . ) |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 Impact |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This produces a slightly larger XML report than the Trace harness, since HighRes times consume more digits than low-res ones. |
|
135
|
|
|
|
|
|
|
This report will be about 20% larger than that of Trace. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over 8 |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item1 MSWin32 |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Approximately 0.8 millisecond per trace (mostly from *::Trace.pm). |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item1 Linux |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
### ########################################################################### |
|
150
|
|
|
|
|
|
|
sub reportTraceInfo { |
|
151
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
Benchmark::Harness::Handler::Trace::reportTraceInfo($self, |
|
154
|
|
|
|
|
|
|
{ |
|
155
|
|
|
|
|
|
|
't' => ( Time::HiRes::time() - $self->[HNDLR_HARNESS]->{_startTime} ) |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
,@_ |
|
158
|
|
|
|
|
|
|
); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
### ########################################################################### |
|
162
|
|
|
|
|
|
|
# USAGE: Benchmark::TraceHighRes::OnSubEntry($harnessSubroutine, \@subrArguments ) |
|
163
|
|
|
|
|
|
|
sub OnSubEntry { |
|
164
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
165
|
0
|
|
|
|
|
|
$self->reportTraceInfo();#(shift, caller(1)); |
|
166
|
0
|
|
|
|
|
|
return @_; # return the input arguments unchanged. |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
### ########################################################################### |
|
170
|
|
|
|
|
|
|
# USAGE: Benchmark::TraceHighRes::OnSubEntry($harnessSubroutine, \@subrReturn ) |
|
171
|
|
|
|
|
|
|
sub OnSubExit { |
|
172
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
173
|
0
|
|
|
|
|
|
$self->reportTraceInfo();#(shift, caller(1)); |
|
174
|
0
|
|
|
|
|
|
return @_; # return the input arguments unchanged. |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
### ########################################################################### |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 AUTHOR |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Glenn Wood, |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Copyright (C) 2004 Glenn Wood. All rights reserved. |
|
187
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
|
188
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |