-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
175 lines (130 loc) · 3.44 KB
/
README
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
NAME
Memory::Process - Perl class to determine actual memory usage.
SYNOPSIS
use Memory::Process;
my $m = Memory::Process->new(%params);
$m->dump;
$m->record($message, $pid);
my @report = $m->report;
my $report = $m->report;
$m->reset;
$m->state;
METHODS
"new"
my $m = Memory::Process->new(%params);
Constructor.
Returns instance of object.
"dump"
$m->dump;
Print report to STDERR.
Returns return value of print().
"record"
$m->record($message, $pid);
Set record. If message not set, use ''.
Returns undef.
"report"
my @report = $m->report;
my $report = $m->report;
Get report.
In scalar context returns string with report. In array context returns
array of report lines. First line is title.
"reset"
$m->reset;
Reset records.
Returns undef.
"state"
$m->state;
Get internal state.
Each state item consists from:
- timestamp (in seconds since epoch)
- message (from record())
- virtual memory size (in kB)
- resident set size (in kB)
- shared memory size (in kB)
- text size (in kB)
- data and stack size (in kB)
Returns reference to array with state items.
EXAMPLE1
use strict;
use warnings;
use Memory::Process;
# Object.
my $m = Memory::Process->new;
# Example process.
$m->record("Before my big method");
my $var = ('foo' x 100);
sleep 1;
$m->record("After my big method");
sleep 1;
$m->record("End");
# Print report.
print $m->report."\n";
# Output like:
# time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff)
# 1 19120 ( 0) 2464 ( 0) 1824 ( 0) 8 ( 0) 1056 ( 0) After my big method
# 2 19120 ( 0) 2464 ( 0) 1824 ( 0) 8 ( 0) 1056 ( 0) End
EXAMPLE2
use strict;
use warnings;
use Data::Printer;
use Memory::Process;
# Object.
my $m = Memory::Process->new;
# Example process.
$m->record("Before my big method");
my $var = ('foo' x 100);
sleep 1;
$m->record("After my big method");
sleep 1;
$m->record("End");
# Print report.
my $state_ar = $m->state;
# Dump out.
p $state_ar;
# Output like:
# \ [
# [0] [
# [0] 1445941214,
# [1] "Before my big method",
# [2] 33712,
# [3] 7956,
# [4] 3876,
# [5] 8,
# [6] 4564
# ],
# [1] [
# [0] 1445941215,
# [1] "After my big method",
# [2] 33712,
# [3] 7956,
# [4] 3876,
# [5] 8,
# [6] 4564
# ],
# [2] [
# [0] 1445941216,
# [1] "End",
# [2] 33712,
# [3] 7956,
# [4] 3876,
# [5] 8,
# [6] 4564
# ]
# ]
DEPENDENCIES
Memory::Usage, Readonly.
SEE ALSO
Memory::Stats
Memory Usage Consumption of your process
Memory::Usage
Tools to determine actual memory usage
REPOSITORY
<https://github.com/michal-josef-spacek/Memory-Process>
AUTHOR
Michal Josef Špaček <mailto:skim@cpan.org>
<http://skim.cz/>
LICENSE AND COPYRIGHT
© 2014-2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.07