get_process_mem 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1926d125b830fc4f0f99e8a4a74d68e98ff26e53
4
- data.tar.gz: 49a31e4c798e3b8b9985ee2e7a5f0fbf347e1ec9
3
+ metadata.gz: 52264416d05e8d73e6a2d1245f1f9bca7b043fb2
4
+ data.tar.gz: 5ea9ced69283b2a9e0ea07f08f9dd7d5e928e707
5
5
  SHA512:
6
- metadata.gz: fce55634e47e6282a8fa42d2dd2df39a201c180612a70a6e87fce95dfbf313080fbbe46a80f00b21e62c40b99d9d304c35bcfa1adbb768b6b0e67d1409111bc0
7
- data.tar.gz: cdcbe4cae20d5af9d53a79ec37f89cf2bfdb2d7d211114f78fa89b56cf732c3d39ca6ea39417da13ee1d393a772f8ecc63389ab7b7e26836907238088d29d0fd
6
+ metadata.gz: 7b2446a2c0f9fa8f4c387a5ca82f455b4063874f3516a5615c744a4790eb0e166dcfd03400ac52694fef8f557159f5641377194db6be73e495b01cefa4413ccf
7
+ data.tar.gz: 98d55d7547d8c73e5d87ed91012df5672abc44d71a5b2853d60f0a6fbdead3d6530bbc8891b026361e48856f6c5f8fd39e5c9ae25fa64a9f19536c51b2d7f5be
@@ -1,3 +1,6 @@
1
+ ## 0.1.1
2
+ - Bugfix: the `ps` style of memory reporting should always use RSS, and Linux should always use PSS
3
+
1
4
  ## 0.1.0
2
5
 
3
6
  - Default to using PSS for linux (#2 & #3) @ksoderstrom
@@ -1,19 +1,20 @@
1
1
  require 'pathname'
2
+ require 'bigdecimal'
3
+
2
4
 
3
5
  # Cribbed from Unicorn Worker Killer, thanks!
4
6
  class GetProcessMem
5
7
  KB_TO_BYTE = 1024 # 2**10 = 1024
6
8
  MB_TO_BYTE = 1_048_576 # 1024**2 = 1_048_576
7
9
  GB_TO_BYTE = 1_073_741_824 # 1024**3 = 1_073_741_824
8
- CONVERSION = { "kb" => KB_TO_BYTE, "mb" => MB_TO_BYTE, "gb" => GB_TO_BYTE}
10
+ CONVERSION = { "kb" => KB_TO_BYTE, "mb" => MB_TO_BYTE, "gb" => GB_TO_BYTE }
11
+ ROUND_UP = BigDecimal.new("0.5")
9
12
  attr_reader :pid
10
13
 
11
- def initialize(pid = Process.pid, options = {})
14
+ def initialize(pid = Process.pid)
12
15
  @process_file = Pathname.new "/proc/#{pid}/smaps"
13
16
  @pid = pid
14
17
  @linux = @process_file.exist?
15
- options[:mem_type] ||= @linux ? 'pss' : 'rss'
16
- self.mem_type = options[:mem_type]
17
18
  end
18
19
 
19
20
  def linux?
@@ -26,20 +27,20 @@ class GetProcessMem
26
27
  end
27
28
 
28
29
  def kb(b = bytes)
29
- b.fdiv(KB_TO_BYTE)
30
+ (b/BigDecimal.new(KB_TO_BYTE)).to_f
30
31
  end
31
32
 
32
33
  def mb(b = bytes)
33
- b.fdiv(MB_TO_BYTE)
34
+ (b/BigDecimal.new(MB_TO_BYTE)).to_f
34
35
  end
35
36
 
36
37
  def gb(b = bytes)
37
- b.fdiv(GB_TO_BYTE)
38
+ (b/BigDecimal.new(GB_TO_BYTE)).to_f
38
39
  end
39
40
 
40
41
  def inspect
41
42
  b = bytes
42
- "#<#{self.class}:0x%08x @mb=#{mb b } @gb=#{gb b } @kb=#{kb b } @bytes=#{b}>" % (object_id * 2)
43
+ "#<#{self.class}:0x%08x @mb=#{ mb b } @gb=#{ gb b } @kb=#{ kb b } @bytes=#{b}>" % (object_id * 2)
43
44
  end
44
45
 
45
46
  def mem_type
@@ -50,41 +51,30 @@ class GetProcessMem
50
51
  @mem_type = mem_type.downcase
51
52
  end
52
53
 
53
- private
54
-
55
- # Pull memory from `ps` command, takes more resources and can freeze
56
- # in low memory situations
57
- def ps_memory
58
- KB_TO_BYTE * `ps -o #{mem_type_for_ps}= -p #{pid}`.to_i
59
- end
60
-
61
- def mem_type_for_ps
62
- mem_type
63
- end
64
-
65
- def mem_type_for_linux
66
- case mem_type
67
- when 'rss'
68
- 'Rss'
69
- when 'pss'
70
- 'Pss'
71
- end
72
- end
73
-
74
54
  # linux stores memory info in a file "/proc/#{pid}/smaps"
75
55
  # If it's available it uses less resources than shelling out to ps
76
56
  # It also allows us to use Pss (the process' proportional share of
77
57
  # the mapping that is resident in RAM) as mem_type
78
- def linux_memory
79
- lines = @process_file.each_line.select {|line| line.include? mem_type_for_linux }
80
- return unless lines.length > 0
58
+ def linux_memory(file = @process_file)
59
+ lines = file.each_line.select {|line| line.match /^Pss/ }
60
+ return if lines.empty?
81
61
  lines.reduce(0) do |sum, line|
82
- return unless (name, value, unit = line.split(nil)).length == 3
83
- # The PSS value is truncated, and adding 0.5 should average this out
84
- value = value.to_f + 0.5 if mem_type == 'pss'
85
- sum += CONVERSION[unit.downcase] * value.to_f
62
+ line.match(/(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/) do |m|
63
+ value = BigDecimal.new(m[:value]) + ROUND_UP
64
+ unit = m[:unit].downcase
65
+ sum += CONVERSION[unit] * value
66
+ end
67
+ sum
86
68
  end
87
69
  end
70
+
71
+ private
72
+
73
+ # Pull memory from `ps` command, takes more resources and can freeze
74
+ # in low memory situations
75
+ def ps_memory
76
+ KB_TO_BYTE * BigDecimal.new(`ps -o rss= -p #{pid}`)
77
+ end
88
78
  end
89
79
 
90
80
  GetProcessMem
@@ -1,3 +1,3 @@
1
1
  class GetProcessMem
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,912 @@
1
+ 00400000-004db000 r-xp 00000000 07:01 72877 /bin/bash
2
+ Size: 876 kB
3
+ Rss: 532 kB
4
+ Pss: 532 kB
5
+ Shared_Clean: 0 kB
6
+ Shared_Dirty: 0 kB
7
+ Private_Clean: 532 kB
8
+ Private_Dirty: 0 kB
9
+ Referenced: 532 kB
10
+ Anonymous: 0 kB
11
+ AnonHugePages: 0 kB
12
+ Swap: 0 kB
13
+ KernelPageSize: 4 kB
14
+ MMUPageSize: 4 kB
15
+ Locked: 0 kB
16
+ VmFlags: rd ex mr mw me dw
17
+ 006da000-006db000 r--p 000da000 07:01 72877 /bin/bash
18
+ Size: 4 kB
19
+ Rss: 4 kB
20
+ Pss: 4 kB
21
+ Shared_Clean: 0 kB
22
+ Shared_Dirty: 0 kB
23
+ Private_Clean: 0 kB
24
+ Private_Dirty: 4 kB
25
+ Referenced: 4 kB
26
+ Anonymous: 4 kB
27
+ AnonHugePages: 0 kB
28
+ Swap: 0 kB
29
+ KernelPageSize: 4 kB
30
+ MMUPageSize: 4 kB
31
+ Locked: 0 kB
32
+ VmFlags: rd mr mw me dw ac
33
+ 006db000-006e4000 rw-p 000db000 07:01 72877 /bin/bash
34
+ Size: 36 kB
35
+ Rss: 36 kB
36
+ Pss: 36 kB
37
+ Shared_Clean: 0 kB
38
+ Shared_Dirty: 0 kB
39
+ Private_Clean: 0 kB
40
+ Private_Dirty: 36 kB
41
+ Referenced: 36 kB
42
+ Anonymous: 36 kB
43
+ AnonHugePages: 0 kB
44
+ Swap: 0 kB
45
+ KernelPageSize: 4 kB
46
+ MMUPageSize: 4 kB
47
+ Locked: 0 kB
48
+ VmFlags: rd wr mr mw me dw ac
49
+ 006e4000-006ea000 rw-p 00000000 00:00 0
50
+ Size: 24 kB
51
+ Rss: 24 kB
52
+ Pss: 24 kB
53
+ Shared_Clean: 0 kB
54
+ Shared_Dirty: 0 kB
55
+ Private_Clean: 0 kB
56
+ Private_Dirty: 24 kB
57
+ Referenced: 24 kB
58
+ Anonymous: 24 kB
59
+ AnonHugePages: 0 kB
60
+ Swap: 0 kB
61
+ KernelPageSize: 4 kB
62
+ MMUPageSize: 4 kB
63
+ Locked: 0 kB
64
+ VmFlags: rd wr mr mw me ac
65
+ 020c0000-0210e000 rw-p 00000000 00:00 0 [heap]
66
+ Size: 312 kB
67
+ Rss: 312 kB
68
+ Pss: 312 kB
69
+ Shared_Clean: 0 kB
70
+ Shared_Dirty: 0 kB
71
+ Private_Clean: 0 kB
72
+ Private_Dirty: 312 kB
73
+ Referenced: 312 kB
74
+ Anonymous: 312 kB
75
+ AnonHugePages: 0 kB
76
+ Swap: 0 kB
77
+ KernelPageSize: 4 kB
78
+ MMUPageSize: 4 kB
79
+ Locked: 0 kB
80
+ VmFlags: rd wr mr mw me ac
81
+ 7f28ff505000-7f28ff511000 r-xp 00000000 07:01 81120 /lib/libnss_files-2.11.1.so
82
+ Size: 48 kB
83
+ Rss: 16 kB
84
+ Pss: 0 kB
85
+ Shared_Clean: 16 kB
86
+ Shared_Dirty: 0 kB
87
+ Private_Clean: 0 kB
88
+ Private_Dirty: 0 kB
89
+ Referenced: 16 kB
90
+ Anonymous: 0 kB
91
+ AnonHugePages: 0 kB
92
+ Swap: 0 kB
93
+ KernelPageSize: 4 kB
94
+ MMUPageSize: 4 kB
95
+ Locked: 0 kB
96
+ VmFlags: rd ex mr mw me
97
+ 7f28ff511000-7f28ff710000 ---p 0000c000 07:01 81120 /lib/libnss_files-2.11.1.so
98
+ Size: 2044 kB
99
+ Rss: 0 kB
100
+ Pss: 0 kB
101
+ Shared_Clean: 0 kB
102
+ Shared_Dirty: 0 kB
103
+ Private_Clean: 0 kB
104
+ Private_Dirty: 0 kB
105
+ Referenced: 0 kB
106
+ Anonymous: 0 kB
107
+ AnonHugePages: 0 kB
108
+ Swap: 0 kB
109
+ KernelPageSize: 4 kB
110
+ MMUPageSize: 4 kB
111
+ Locked: 0 kB
112
+ VmFlags: mr mw me
113
+ 7f28ff710000-7f28ff711000 r--p 0000b000 07:01 81120 /lib/libnss_files-2.11.1.so
114
+ Size: 4 kB
115
+ Rss: 4 kB
116
+ Pss: 4 kB
117
+ Shared_Clean: 0 kB
118
+ Shared_Dirty: 0 kB
119
+ Private_Clean: 0 kB
120
+ Private_Dirty: 4 kB
121
+ Referenced: 4 kB
122
+ Anonymous: 4 kB
123
+ AnonHugePages: 0 kB
124
+ Swap: 0 kB
125
+ KernelPageSize: 4 kB
126
+ MMUPageSize: 4 kB
127
+ Locked: 0 kB
128
+ VmFlags: rd mr mw me ac
129
+ 7f28ff711000-7f28ff712000 rw-p 0000c000 07:01 81120 /lib/libnss_files-2.11.1.so
130
+ Size: 4 kB
131
+ Rss: 4 kB
132
+ Pss: 4 kB
133
+ Shared_Clean: 0 kB
134
+ Shared_Dirty: 0 kB
135
+ Private_Clean: 0 kB
136
+ Private_Dirty: 4 kB
137
+ Referenced: 4 kB
138
+ Anonymous: 4 kB
139
+ AnonHugePages: 0 kB
140
+ Swap: 0 kB
141
+ KernelPageSize: 4 kB
142
+ MMUPageSize: 4 kB
143
+ Locked: 0 kB
144
+ VmFlags: rd wr mr mw me ac
145
+ 7f28ff712000-7f28ff71c000 r-xp 00000000 07:01 81122 /lib/libnss_nis-2.11.1.so
146
+ Size: 40 kB
147
+ Rss: 20 kB
148
+ Pss: 0 kB
149
+ Shared_Clean: 20 kB
150
+ Shared_Dirty: 0 kB
151
+ Private_Clean: 0 kB
152
+ Private_Dirty: 0 kB
153
+ Referenced: 20 kB
154
+ Anonymous: 0 kB
155
+ AnonHugePages: 0 kB
156
+ Swap: 0 kB
157
+ KernelPageSize: 4 kB
158
+ MMUPageSize: 4 kB
159
+ Locked: 0 kB
160
+ VmFlags: rd ex mr mw me
161
+ 7f28ff71c000-7f28ff91b000 ---p 0000a000 07:01 81122 /lib/libnss_nis-2.11.1.so
162
+ Size: 2044 kB
163
+ Rss: 0 kB
164
+ Pss: 0 kB
165
+ Shared_Clean: 0 kB
166
+ Shared_Dirty: 0 kB
167
+ Private_Clean: 0 kB
168
+ Private_Dirty: 0 kB
169
+ Referenced: 0 kB
170
+ Anonymous: 0 kB
171
+ AnonHugePages: 0 kB
172
+ Swap: 0 kB
173
+ KernelPageSize: 4 kB
174
+ MMUPageSize: 4 kB
175
+ Locked: 0 kB
176
+ VmFlags: mr mw me
177
+ 7f28ff91b000-7f28ff91c000 r--p 00009000 07:01 81122 /lib/libnss_nis-2.11.1.so
178
+ Size: 4 kB
179
+ Rss: 4 kB
180
+ Pss: 4 kB
181
+ Shared_Clean: 0 kB
182
+ Shared_Dirty: 0 kB
183
+ Private_Clean: 0 kB
184
+ Private_Dirty: 4 kB
185
+ Referenced: 4 kB
186
+ Anonymous: 4 kB
187
+ AnonHugePages: 0 kB
188
+ Swap: 0 kB
189
+ KernelPageSize: 4 kB
190
+ MMUPageSize: 4 kB
191
+ Locked: 0 kB
192
+ VmFlags: rd mr mw me ac
193
+ 7f28ff91c000-7f28ff91d000 rw-p 0000a000 07:01 81122 /lib/libnss_nis-2.11.1.so
194
+ Size: 4 kB
195
+ Rss: 4 kB
196
+ Pss: 4 kB
197
+ Shared_Clean: 0 kB
198
+ Shared_Dirty: 0 kB
199
+ Private_Clean: 0 kB
200
+ Private_Dirty: 4 kB
201
+ Referenced: 4 kB
202
+ Anonymous: 4 kB
203
+ AnonHugePages: 0 kB
204
+ Swap: 0 kB
205
+ KernelPageSize: 4 kB
206
+ MMUPageSize: 4 kB
207
+ Locked: 0 kB
208
+ VmFlags: rd wr mr mw me ac
209
+ 7f28ff91d000-7f28ff934000 r-xp 00000000 07:01 81117 /lib/libnsl-2.11.1.so
210
+ Size: 92 kB
211
+ Rss: 24 kB
212
+ Pss: 0 kB
213
+ Shared_Clean: 24 kB
214
+ Shared_Dirty: 0 kB
215
+ Private_Clean: 0 kB
216
+ Private_Dirty: 0 kB
217
+ Referenced: 24 kB
218
+ Anonymous: 0 kB
219
+ AnonHugePages: 0 kB
220
+ Swap: 0 kB
221
+ KernelPageSize: 4 kB
222
+ MMUPageSize: 4 kB
223
+ Locked: 0 kB
224
+ VmFlags: rd ex mr mw me
225
+ 7f28ff934000-7f28ffb33000 ---p 00017000 07:01 81117 /lib/libnsl-2.11.1.so
226
+ Size: 2044 kB
227
+ Rss: 0 kB
228
+ Pss: 0 kB
229
+ Shared_Clean: 0 kB
230
+ Shared_Dirty: 0 kB
231
+ Private_Clean: 0 kB
232
+ Private_Dirty: 0 kB
233
+ Referenced: 0 kB
234
+ Anonymous: 0 kB
235
+ AnonHugePages: 0 kB
236
+ Swap: 0 kB
237
+ KernelPageSize: 4 kB
238
+ MMUPageSize: 4 kB
239
+ Locked: 0 kB
240
+ VmFlags: mr mw me
241
+ 7f28ffb33000-7f28ffb34000 r--p 00016000 07:01 81117 /lib/libnsl-2.11.1.so
242
+ Size: 4 kB
243
+ Rss: 4 kB
244
+ Pss: 4 kB
245
+ Shared_Clean: 0 kB
246
+ Shared_Dirty: 0 kB
247
+ Private_Clean: 0 kB
248
+ Private_Dirty: 4 kB
249
+ Referenced: 4 kB
250
+ Anonymous: 4 kB
251
+ AnonHugePages: 0 kB
252
+ Swap: 0 kB
253
+ KernelPageSize: 4 kB
254
+ MMUPageSize: 4 kB
255
+ Locked: 0 kB
256
+ VmFlags: rd mr mw me ac
257
+ 7f28ffb34000-7f28ffb35000 rw-p 00017000 07:01 81117 /lib/libnsl-2.11.1.so
258
+ Size: 4 kB
259
+ Rss: 4 kB
260
+ Pss: 4 kB
261
+ Shared_Clean: 0 kB
262
+ Shared_Dirty: 0 kB
263
+ Private_Clean: 0 kB
264
+ Private_Dirty: 4 kB
265
+ Referenced: 4 kB
266
+ Anonymous: 4 kB
267
+ AnonHugePages: 0 kB
268
+ Swap: 0 kB
269
+ KernelPageSize: 4 kB
270
+ MMUPageSize: 4 kB
271
+ Locked: 0 kB
272
+ VmFlags: rd wr mr mw me ac
273
+ 7f28ffb35000-7f28ffb37000 rw-p 00000000 00:00 0
274
+ Size: 8 kB
275
+ Rss: 0 kB
276
+ Pss: 0 kB
277
+ Shared_Clean: 0 kB
278
+ Shared_Dirty: 0 kB
279
+ Private_Clean: 0 kB
280
+ Private_Dirty: 0 kB
281
+ Referenced: 0 kB
282
+ Anonymous: 0 kB
283
+ AnonHugePages: 0 kB
284
+ Swap: 0 kB
285
+ KernelPageSize: 4 kB
286
+ MMUPageSize: 4 kB
287
+ Locked: 0 kB
288
+ VmFlags: rd wr mr mw me ac
289
+ 7f28ffb37000-7f28ffb3f000 r-xp 00000000 07:01 81118 /lib/libnss_compat-2.11.1.so
290
+ Size: 32 kB
291
+ Rss: 24 kB
292
+ Pss: 0 kB
293
+ Shared_Clean: 24 kB
294
+ Shared_Dirty: 0 kB
295
+ Private_Clean: 0 kB
296
+ Private_Dirty: 0 kB
297
+ Referenced: 24 kB
298
+ Anonymous: 0 kB
299
+ AnonHugePages: 0 kB
300
+ Swap: 0 kB
301
+ KernelPageSize: 4 kB
302
+ MMUPageSize: 4 kB
303
+ Locked: 0 kB
304
+ VmFlags: rd ex mr mw me
305
+ 7f28ffb3f000-7f28ffd3e000 ---p 00008000 07:01 81118 /lib/libnss_compat-2.11.1.so
306
+ Size: 2044 kB
307
+ Rss: 0 kB
308
+ Pss: 0 kB
309
+ Shared_Clean: 0 kB
310
+ Shared_Dirty: 0 kB
311
+ Private_Clean: 0 kB
312
+ Private_Dirty: 0 kB
313
+ Referenced: 0 kB
314
+ Anonymous: 0 kB
315
+ AnonHugePages: 0 kB
316
+ Swap: 0 kB
317
+ KernelPageSize: 4 kB
318
+ MMUPageSize: 4 kB
319
+ Locked: 0 kB
320
+ VmFlags: mr mw me
321
+ 7f28ffd3e000-7f28ffd3f000 r--p 00007000 07:01 81118 /lib/libnss_compat-2.11.1.so
322
+ Size: 4 kB
323
+ Rss: 4 kB
324
+ Pss: 4 kB
325
+ Shared_Clean: 0 kB
326
+ Shared_Dirty: 0 kB
327
+ Private_Clean: 0 kB
328
+ Private_Dirty: 4 kB
329
+ Referenced: 4 kB
330
+ Anonymous: 4 kB
331
+ AnonHugePages: 0 kB
332
+ Swap: 0 kB
333
+ KernelPageSize: 4 kB
334
+ MMUPageSize: 4 kB
335
+ Locked: 0 kB
336
+ VmFlags: rd mr mw me ac
337
+ 7f28ffd3f000-7f28ffd40000 rw-p 00008000 07:01 81118 /lib/libnss_compat-2.11.1.so
338
+ Size: 4 kB
339
+ Rss: 4 kB
340
+ Pss: 4 kB
341
+ Shared_Clean: 0 kB
342
+ Shared_Dirty: 0 kB
343
+ Private_Clean: 0 kB
344
+ Private_Dirty: 4 kB
345
+ Referenced: 4 kB
346
+ Anonymous: 4 kB
347
+ AnonHugePages: 0 kB
348
+ Swap: 0 kB
349
+ KernelPageSize: 4 kB
350
+ MMUPageSize: 4 kB
351
+ Locked: 0 kB
352
+ VmFlags: rd wr mr mw me ac
353
+ 7f28ffd40000-7f28ffebd000 r-xp 00000000 07:01 81088 /lib/libc-2.11.1.so
354
+ Size: 1524 kB
355
+ Rss: 540 kB
356
+ Pss: 10 kB
357
+ Shared_Clean: 532 kB
358
+ Shared_Dirty: 0 kB
359
+ Private_Clean: 8 kB
360
+ Private_Dirty: 0 kB
361
+ Referenced: 540 kB
362
+ Anonymous: 0 kB
363
+ AnonHugePages: 0 kB
364
+ Swap: 0 kB
365
+ KernelPageSize: 4 kB
366
+ MMUPageSize: 4 kB
367
+ Locked: 0 kB
368
+ VmFlags: rd ex mr mw me
369
+ 7f28ffebd000-7f29000bc000 ---p 0017d000 07:01 81088 /lib/libc-2.11.1.so
370
+ Size: 2044 kB
371
+ Rss: 0 kB
372
+ Pss: 0 kB
373
+ Shared_Clean: 0 kB
374
+ Shared_Dirty: 0 kB
375
+ Private_Clean: 0 kB
376
+ Private_Dirty: 0 kB
377
+ Referenced: 0 kB
378
+ Anonymous: 0 kB
379
+ AnonHugePages: 0 kB
380
+ Swap: 0 kB
381
+ KernelPageSize: 4 kB
382
+ MMUPageSize: 4 kB
383
+ Locked: 0 kB
384
+ VmFlags: mr mw me
385
+ 7f29000bc000-7f29000c0000 r--p 0017c000 07:01 81088 /lib/libc-2.11.1.so
386
+ Size: 16 kB
387
+ Rss: 16 kB
388
+ Pss: 16 kB
389
+ Shared_Clean: 0 kB
390
+ Shared_Dirty: 0 kB
391
+ Private_Clean: 0 kB
392
+ Private_Dirty: 16 kB
393
+ Referenced: 16 kB
394
+ Anonymous: 16 kB
395
+ AnonHugePages: 0 kB
396
+ Swap: 0 kB
397
+ KernelPageSize: 4 kB
398
+ MMUPageSize: 4 kB
399
+ Locked: 0 kB
400
+ VmFlags: rd mr mw me ac
401
+ 7f29000c0000-7f29000c1000 rw-p 00180000 07:01 81088 /lib/libc-2.11.1.so
402
+ Size: 4 kB
403
+ Rss: 4 kB
404
+ Pss: 4 kB
405
+ Shared_Clean: 0 kB
406
+ Shared_Dirty: 0 kB
407
+ Private_Clean: 0 kB
408
+ Private_Dirty: 4 kB
409
+ Referenced: 4 kB
410
+ Anonymous: 4 kB
411
+ AnonHugePages: 0 kB
412
+ Swap: 0 kB
413
+ KernelPageSize: 4 kB
414
+ MMUPageSize: 4 kB
415
+ Locked: 0 kB
416
+ VmFlags: rd wr mr mw me ac
417
+ 7f29000c1000-7f29000c6000 rw-p 00000000 00:00 0
418
+ Size: 20 kB
419
+ Rss: 16 kB
420
+ Pss: 16 kB
421
+ Shared_Clean: 0 kB
422
+ Shared_Dirty: 0 kB
423
+ Private_Clean: 0 kB
424
+ Private_Dirty: 16 kB
425
+ Referenced: 16 kB
426
+ Anonymous: 16 kB
427
+ AnonHugePages: 0 kB
428
+ Swap: 0 kB
429
+ KernelPageSize: 4 kB
430
+ MMUPageSize: 4 kB
431
+ Locked: 0 kB
432
+ VmFlags: rd wr mr mw me ac
433
+ 7f29000c6000-7f29000c8000 r-xp 00000000 07:01 81095 /lib/libdl-2.11.1.so
434
+ Size: 8 kB
435
+ Rss: 8 kB
436
+ Pss: 0 kB
437
+ Shared_Clean: 8 kB
438
+ Shared_Dirty: 0 kB
439
+ Private_Clean: 0 kB
440
+ Private_Dirty: 0 kB
441
+ Referenced: 8 kB
442
+ Anonymous: 0 kB
443
+ AnonHugePages: 0 kB
444
+ Swap: 0 kB
445
+ KernelPageSize: 4 kB
446
+ MMUPageSize: 4 kB
447
+ Locked: 0 kB
448
+ VmFlags: rd ex mr mw me
449
+ 7f29000c8000-7f29002c8000 ---p 00002000 07:01 81095 /lib/libdl-2.11.1.so
450
+ Size: 2048 kB
451
+ Rss: 0 kB
452
+ Pss: 0 kB
453
+ Shared_Clean: 0 kB
454
+ Shared_Dirty: 0 kB
455
+ Private_Clean: 0 kB
456
+ Private_Dirty: 0 kB
457
+ Referenced: 0 kB
458
+ Anonymous: 0 kB
459
+ AnonHugePages: 0 kB
460
+ Swap: 0 kB
461
+ KernelPageSize: 4 kB
462
+ MMUPageSize: 4 kB
463
+ Locked: 0 kB
464
+ VmFlags: mr mw me
465
+ 7f29002c8000-7f29002c9000 r--p 00002000 07:01 81095 /lib/libdl-2.11.1.so
466
+ Size: 4 kB
467
+ Rss: 4 kB
468
+ Pss: 4 kB
469
+ Shared_Clean: 0 kB
470
+ Shared_Dirty: 0 kB
471
+ Private_Clean: 0 kB
472
+ Private_Dirty: 4 kB
473
+ Referenced: 4 kB
474
+ Anonymous: 4 kB
475
+ AnonHugePages: 0 kB
476
+ Swap: 0 kB
477
+ KernelPageSize: 4 kB
478
+ MMUPageSize: 4 kB
479
+ Locked: 0 kB
480
+ VmFlags: rd mr mw me ac
481
+ 7f29002c9000-7f29002ca000 rw-p 00003000 07:01 81095 /lib/libdl-2.11.1.so
482
+ Size: 4 kB
483
+ Rss: 4 kB
484
+ Pss: 4 kB
485
+ Shared_Clean: 0 kB
486
+ Shared_Dirty: 0 kB
487
+ Private_Clean: 0 kB
488
+ Private_Dirty: 4 kB
489
+ Referenced: 4 kB
490
+ Anonymous: 4 kB
491
+ AnonHugePages: 0 kB
492
+ Swap: 0 kB
493
+ KernelPageSize: 4 kB
494
+ MMUPageSize: 4 kB
495
+ Locked: 0 kB
496
+ VmFlags: rd wr mr mw me ac
497
+ 7f29002ca000-7f2900308000 r-xp 00000000 07:01 81113 /lib/libncurses.so.5.7
498
+ Size: 248 kB
499
+ Rss: 136 kB
500
+ Pss: 77 kB
501
+ Shared_Clean: 68 kB
502
+ Shared_Dirty: 0 kB
503
+ Private_Clean: 68 kB
504
+ Private_Dirty: 0 kB
505
+ Referenced: 136 kB
506
+ Anonymous: 0 kB
507
+ AnonHugePages: 0 kB
508
+ Swap: 0 kB
509
+ KernelPageSize: 4 kB
510
+ MMUPageSize: 4 kB
511
+ Locked: 0 kB
512
+ VmFlags: rd ex mr mw me
513
+ 7f2900308000-7f2900508000 ---p 0003e000 07:01 81113 /lib/libncurses.so.5.7
514
+ Size: 2048 kB
515
+ Rss: 0 kB
516
+ Pss: 0 kB
517
+ Shared_Clean: 0 kB
518
+ Shared_Dirty: 0 kB
519
+ Private_Clean: 0 kB
520
+ Private_Dirty: 0 kB
521
+ Referenced: 0 kB
522
+ Anonymous: 0 kB
523
+ AnonHugePages: 0 kB
524
+ Swap: 0 kB
525
+ KernelPageSize: 4 kB
526
+ MMUPageSize: 4 kB
527
+ Locked: 0 kB
528
+ VmFlags: mr mw me
529
+ 7f2900508000-7f290050c000 r--p 0003e000 07:01 81113 /lib/libncurses.so.5.7
530
+ Size: 16 kB
531
+ Rss: 16 kB
532
+ Pss: 16 kB
533
+ Shared_Clean: 0 kB
534
+ Shared_Dirty: 0 kB
535
+ Private_Clean: 0 kB
536
+ Private_Dirty: 16 kB
537
+ Referenced: 16 kB
538
+ Anonymous: 16 kB
539
+ AnonHugePages: 0 kB
540
+ Swap: 0 kB
541
+ KernelPageSize: 4 kB
542
+ MMUPageSize: 4 kB
543
+ Locked: 0 kB
544
+ VmFlags: rd mr mw me ac
545
+ 7f290050c000-7f290050d000 rw-p 00042000 07:01 81113 /lib/libncurses.so.5.7
546
+ Size: 4 kB
547
+ Rss: 4 kB
548
+ Pss: 4 kB
549
+ Shared_Clean: 0 kB
550
+ Shared_Dirty: 0 kB
551
+ Private_Clean: 0 kB
552
+ Private_Dirty: 4 kB
553
+ Referenced: 4 kB
554
+ Anonymous: 4 kB
555
+ AnonHugePages: 0 kB
556
+ Swap: 0 kB
557
+ KernelPageSize: 4 kB
558
+ MMUPageSize: 4 kB
559
+ Locked: 0 kB
560
+ VmFlags: rd wr mr mw me ac
561
+ 7f290050d000-7f290052d000 r-xp 00000000 07:01 81079 /lib/ld-2.11.1.so
562
+ Size: 128 kB
563
+ Rss: 112 kB
564
+ Pss: 0 kB
565
+ Shared_Clean: 112 kB
566
+ Shared_Dirty: 0 kB
567
+ Private_Clean: 0 kB
568
+ Private_Dirty: 0 kB
569
+ Referenced: 112 kB
570
+ Anonymous: 0 kB
571
+ AnonHugePages: 0 kB
572
+ Swap: 0 kB
573
+ KernelPageSize: 4 kB
574
+ MMUPageSize: 4 kB
575
+ Locked: 0 kB
576
+ VmFlags: rd ex mr mw me dw
577
+ 7f29005b9000-7f29005f8000 r--p 00000000 07:01 33875 /usr/lib/locale/en_US.utf8/LC_CTYPE
578
+ Size: 252 kB
579
+ Rss: 24 kB
580
+ Pss: 8 kB
581
+ Shared_Clean: 16 kB
582
+ Shared_Dirty: 0 kB
583
+ Private_Clean: 8 kB
584
+ Private_Dirty: 0 kB
585
+ Referenced: 24 kB
586
+ Anonymous: 0 kB
587
+ AnonHugePages: 0 kB
588
+ Swap: 0 kB
589
+ KernelPageSize: 4 kB
590
+ MMUPageSize: 4 kB
591
+ Locked: 0 kB
592
+ VmFlags: rd mr mw me
593
+ 7f29005f8000-7f2900716000 r--p 00000000 07:01 33874 /usr/lib/locale/en_US.utf8/LC_COLLATE
594
+ Size: 1144 kB
595
+ Rss: 12 kB
596
+ Pss: 1 kB
597
+ Shared_Clean: 12 kB
598
+ Shared_Dirty: 0 kB
599
+ Private_Clean: 0 kB
600
+ Private_Dirty: 0 kB
601
+ Referenced: 12 kB
602
+ Anonymous: 0 kB
603
+ AnonHugePages: 0 kB
604
+ Swap: 0 kB
605
+ KernelPageSize: 4 kB
606
+ MMUPageSize: 4 kB
607
+ Locked: 0 kB
608
+ VmFlags: rd mr mw me
609
+ 7f2900716000-7f2900719000 rw-p 00000000 00:00 0
610
+ Size: 12 kB
611
+ Rss: 12 kB
612
+ Pss: 12 kB
613
+ Shared_Clean: 0 kB
614
+ Shared_Dirty: 0 kB
615
+ Private_Clean: 0 kB
616
+ Private_Dirty: 12 kB
617
+ Referenced: 12 kB
618
+ Anonymous: 12 kB
619
+ AnonHugePages: 0 kB
620
+ Swap: 0 kB
621
+ KernelPageSize: 4 kB
622
+ MMUPageSize: 4 kB
623
+ Locked: 0 kB
624
+ VmFlags: rd wr mr mw me ac
625
+ 7f2900719000-7f290071a000 r--p 00000000 07:01 33880 /usr/lib/locale/en_US.utf8/LC_NUMERIC
626
+ Size: 4 kB
627
+ Rss: 4 kB
628
+ Pss: 0 kB
629
+ Shared_Clean: 4 kB
630
+ Shared_Dirty: 0 kB
631
+ Private_Clean: 0 kB
632
+ Private_Dirty: 0 kB
633
+ Referenced: 4 kB
634
+ Anonymous: 0 kB
635
+ AnonHugePages: 0 kB
636
+ Swap: 0 kB
637
+ KernelPageSize: 4 kB
638
+ MMUPageSize: 4 kB
639
+ Locked: 0 kB
640
+ VmFlags: rd mr mw me
641
+ 7f290071a000-7f290071b000 r--p 00000000 07:01 33883 /usr/lib/locale/en_US.utf8/LC_TIME
642
+ Size: 4 kB
643
+ Rss: 4 kB
644
+ Pss: 0 kB
645
+ Shared_Clean: 4 kB
646
+ Shared_Dirty: 0 kB
647
+ Private_Clean: 0 kB
648
+ Private_Dirty: 0 kB
649
+ Referenced: 4 kB
650
+ Anonymous: 0 kB
651
+ AnonHugePages: 0 kB
652
+ Swap: 0 kB
653
+ KernelPageSize: 4 kB
654
+ MMUPageSize: 4 kB
655
+ Locked: 0 kB
656
+ VmFlags: rd mr mw me
657
+ 7f290071b000-7f290071c000 r--p 00000000 07:01 33878 /usr/lib/locale/en_US.utf8/LC_MONETARY
658
+ Size: 4 kB
659
+ Rss: 4 kB
660
+ Pss: 0 kB
661
+ Shared_Clean: 4 kB
662
+ Shared_Dirty: 0 kB
663
+ Private_Clean: 0 kB
664
+ Private_Dirty: 0 kB
665
+ Referenced: 4 kB
666
+ Anonymous: 0 kB
667
+ AnonHugePages: 0 kB
668
+ Swap: 0 kB
669
+ KernelPageSize: 4 kB
670
+ MMUPageSize: 4 kB
671
+ Locked: 0 kB
672
+ VmFlags: rd mr mw me
673
+ 7f290071c000-7f290071d000 r--p 00000000 07:01 48708 /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES
674
+ Size: 4 kB
675
+ Rss: 4 kB
676
+ Pss: 0 kB
677
+ Shared_Clean: 4 kB
678
+ Shared_Dirty: 0 kB
679
+ Private_Clean: 0 kB
680
+ Private_Dirty: 0 kB
681
+ Referenced: 4 kB
682
+ Anonymous: 0 kB
683
+ AnonHugePages: 0 kB
684
+ Swap: 0 kB
685
+ KernelPageSize: 4 kB
686
+ MMUPageSize: 4 kB
687
+ Locked: 0 kB
688
+ VmFlags: rd mr mw me
689
+ 7f290071d000-7f290071e000 r--p 00000000 07:01 33881 /usr/lib/locale/en_US.utf8/LC_PAPER
690
+ Size: 4 kB
691
+ Rss: 4 kB
692
+ Pss: 0 kB
693
+ Shared_Clean: 4 kB
694
+ Shared_Dirty: 0 kB
695
+ Private_Clean: 0 kB
696
+ Private_Dirty: 0 kB
697
+ Referenced: 4 kB
698
+ Anonymous: 0 kB
699
+ AnonHugePages: 0 kB
700
+ Swap: 0 kB
701
+ KernelPageSize: 4 kB
702
+ MMUPageSize: 4 kB
703
+ Locked: 0 kB
704
+ VmFlags: rd mr mw me
705
+ 7f290071e000-7f290071f000 r--p 00000000 07:01 33879 /usr/lib/locale/en_US.utf8/LC_NAME
706
+ Size: 4 kB
707
+ Rss: 4 kB
708
+ Pss: 0 kB
709
+ Shared_Clean: 4 kB
710
+ Shared_Dirty: 0 kB
711
+ Private_Clean: 0 kB
712
+ Private_Dirty: 0 kB
713
+ Referenced: 4 kB
714
+ Anonymous: 0 kB
715
+ AnonHugePages: 0 kB
716
+ Swap: 0 kB
717
+ KernelPageSize: 4 kB
718
+ MMUPageSize: 4 kB
719
+ Locked: 0 kB
720
+ VmFlags: rd mr mw me
721
+ 7f290071f000-7f2900720000 r--p 00000000 07:01 33873 /usr/lib/locale/en_US.utf8/LC_ADDRESS
722
+ Size: 4 kB
723
+ Rss: 4 kB
724
+ Pss: 0 kB
725
+ Shared_Clean: 4 kB
726
+ Shared_Dirty: 0 kB
727
+ Private_Clean: 0 kB
728
+ Private_Dirty: 0 kB
729
+ Referenced: 4 kB
730
+ Anonymous: 0 kB
731
+ AnonHugePages: 0 kB
732
+ Swap: 0 kB
733
+ KernelPageSize: 4 kB
734
+ MMUPageSize: 4 kB
735
+ Locked: 0 kB
736
+ VmFlags: rd mr mw me
737
+ 7f2900720000-7f2900721000 r--p 00000000 07:01 33882 /usr/lib/locale/en_US.utf8/LC_TELEPHONE
738
+ Size: 4 kB
739
+ Rss: 4 kB
740
+ Pss: 0 kB
741
+ Shared_Clean: 4 kB
742
+ Shared_Dirty: 0 kB
743
+ Private_Clean: 0 kB
744
+ Private_Dirty: 0 kB
745
+ Referenced: 4 kB
746
+ Anonymous: 0 kB
747
+ AnonHugePages: 0 kB
748
+ Swap: 0 kB
749
+ KernelPageSize: 4 kB
750
+ MMUPageSize: 4 kB
751
+ Locked: 0 kB
752
+ VmFlags: rd mr mw me
753
+ 7f2900721000-7f2900722000 r--p 00000000 07:01 33877 /usr/lib/locale/en_US.utf8/LC_MEASUREMENT
754
+ Size: 4 kB
755
+ Rss: 4 kB
756
+ Pss: 0 kB
757
+ Shared_Clean: 4 kB
758
+ Shared_Dirty: 0 kB
759
+ Private_Clean: 0 kB
760
+ Private_Dirty: 0 kB
761
+ Referenced: 4 kB
762
+ Anonymous: 0 kB
763
+ AnonHugePages: 0 kB
764
+ Swap: 0 kB
765
+ KernelPageSize: 4 kB
766
+ MMUPageSize: 4 kB
767
+ Locked: 0 kB
768
+ VmFlags: rd mr mw me
769
+ 7f2900722000-7f2900729000 r--s 00000000 07:01 97395 /usr/lib/gconv/gconv-modules.cache
770
+ Size: 28 kB
771
+ Rss: 20 kB
772
+ Pss: 0 kB
773
+ Shared_Clean: 20 kB
774
+ Shared_Dirty: 0 kB
775
+ Private_Clean: 0 kB
776
+ Private_Dirty: 0 kB
777
+ Referenced: 20 kB
778
+ Anonymous: 0 kB
779
+ AnonHugePages: 0 kB
780
+ Swap: 0 kB
781
+ KernelPageSize: 4 kB
782
+ MMUPageSize: 4 kB
783
+ Locked: 0 kB
784
+ VmFlags: rd mr me ms
785
+ 7f2900729000-7f290072a000 r--p 00000000 07:01 33876 /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
786
+ Size: 4 kB
787
+ Rss: 4 kB
788
+ Pss: 0 kB
789
+ Shared_Clean: 4 kB
790
+ Shared_Dirty: 0 kB
791
+ Private_Clean: 0 kB
792
+ Private_Dirty: 0 kB
793
+ Referenced: 4 kB
794
+ Anonymous: 0 kB
795
+ AnonHugePages: 0 kB
796
+ Swap: 0 kB
797
+ KernelPageSize: 4 kB
798
+ MMUPageSize: 4 kB
799
+ Locked: 0 kB
800
+ VmFlags: rd mr mw me
801
+ 7f290072a000-7f290072c000 rw-p 00000000 00:00 0
802
+ Size: 8 kB
803
+ Rss: 8 kB
804
+ Pss: 8 kB
805
+ Shared_Clean: 0 kB
806
+ Shared_Dirty: 0 kB
807
+ Private_Clean: 0 kB
808
+ Private_Dirty: 8 kB
809
+ Referenced: 8 kB
810
+ Anonymous: 8 kB
811
+ AnonHugePages: 0 kB
812
+ Swap: 0 kB
813
+ KernelPageSize: 4 kB
814
+ MMUPageSize: 4 kB
815
+ Locked: 0 kB
816
+ VmFlags: rd wr mr mw me ac
817
+ 7f290072c000-7f290072d000 r--p 0001f000 07:01 81079 /lib/ld-2.11.1.so
818
+ Size: 4 kB
819
+ Rss: 4 kB
820
+ Pss: 4 kB
821
+ Shared_Clean: 0 kB
822
+ Shared_Dirty: 0 kB
823
+ Private_Clean: 0 kB
824
+ Private_Dirty: 4 kB
825
+ Referenced: 4 kB
826
+ Anonymous: 4 kB
827
+ AnonHugePages: 0 kB
828
+ Swap: 0 kB
829
+ KernelPageSize: 4 kB
830
+ MMUPageSize: 4 kB
831
+ Locked: 0 kB
832
+ VmFlags: rd mr mw me dw ac
833
+ 7f290072d000-7f290072e000 rw-p 00020000 07:01 81079 /lib/ld-2.11.1.so
834
+ Size: 4 kB
835
+ Rss: 4 kB
836
+ Pss: 4 kB
837
+ Shared_Clean: 0 kB
838
+ Shared_Dirty: 0 kB
839
+ Private_Clean: 0 kB
840
+ Private_Dirty: 4 kB
841
+ Referenced: 4 kB
842
+ Anonymous: 4 kB
843
+ AnonHugePages: 0 kB
844
+ Swap: 0 kB
845
+ KernelPageSize: 4 kB
846
+ MMUPageSize: 4 kB
847
+ Locked: 0 kB
848
+ VmFlags: rd wr mr mw me dw ac
849
+ 7f290072e000-7f290072f000 rw-p 00000000 00:00 0
850
+ Size: 4 kB
851
+ Rss: 4 kB
852
+ Pss: 4 kB
853
+ Shared_Clean: 0 kB
854
+ Shared_Dirty: 0 kB
855
+ Private_Clean: 0 kB
856
+ Private_Dirty: 4 kB
857
+ Referenced: 4 kB
858
+ Anonymous: 4 kB
859
+ AnonHugePages: 0 kB
860
+ Swap: 0 kB
861
+ KernelPageSize: 4 kB
862
+ MMUPageSize: 4 kB
863
+ Locked: 0 kB
864
+ VmFlags: rd wr mr mw me ac
865
+ 7ffff83a4000-7ffff83c5000 rw-p 00000000 00:00 0 [stack]
866
+ Size: 136 kB
867
+ Rss: 28 kB
868
+ Pss: 28 kB
869
+ Shared_Clean: 0 kB
870
+ Shared_Dirty: 0 kB
871
+ Private_Clean: 0 kB
872
+ Private_Dirty: 28 kB
873
+ Referenced: 28 kB
874
+ Anonymous: 28 kB
875
+ AnonHugePages: 0 kB
876
+ Swap: 0 kB
877
+ KernelPageSize: 4 kB
878
+ MMUPageSize: 4 kB
879
+ Locked: 0 kB
880
+ VmFlags: rd wr mr mw me gd ac
881
+ 7ffff83fe000-7ffff8400000 r-xp 00000000 00:00 0 [vdso]
882
+ Size: 8 kB
883
+ Rss: 4 kB
884
+ Pss: 0 kB
885
+ Shared_Clean: 4 kB
886
+ Shared_Dirty: 0 kB
887
+ Private_Clean: 0 kB
888
+ Private_Dirty: 0 kB
889
+ Referenced: 4 kB
890
+ Anonymous: 0 kB
891
+ AnonHugePages: 0 kB
892
+ Swap: 0 kB
893
+ KernelPageSize: 4 kB
894
+ MMUPageSize: 4 kB
895
+ Locked: 0 kB
896
+ VmFlags: rd ex mr mw me de
897
+ ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
898
+ Size: 4 kB
899
+ Rss: 0 kB
900
+ Pss: 0 kB
901
+ Shared_Clean: 0 kB
902
+ Shared_Dirty: 0 kB
903
+ Private_Clean: 0 kB
904
+ Private_Dirty: 0 kB
905
+ Referenced: 0 kB
906
+ Anonymous: 0 kB
907
+ AnonHugePages: 0 kB
908
+ Swap: 0 kB
909
+ KernelPageSize: 4 kB
910
+ MMUPageSize: 4 kB
911
+ Locked: 0 kB
912
+ VmFlags: rd ex
@@ -13,28 +13,35 @@ class GetProcessMemTest < Test::Unit::TestCase
13
13
  assert @mem.bytes > 0
14
14
  end
15
15
 
16
+ def test_linux_smap
17
+ delta = 1
18
+ bytes = @mem.linux_memory(fixture_path("heroku-bash-smap"))
19
+ assert_in_delta BigDecimal.new("1217024.0"), bytes, delta
20
+ end
21
+
16
22
  def test_conversions
17
23
  bytes = 0
18
- assert_equal 0.0, @mem.kb(bytes)
19
- assert_equal 0.0, @mem.mb(bytes)
20
- assert_equal 0.0, @mem.gb(bytes)
24
+ delta = BigDecimal.new("0.0000001")
25
+ assert_in_delta 0.0, @mem.kb(bytes), delta
26
+ assert_in_delta 0.0, @mem.mb(bytes), delta
27
+ assert_in_delta 0.0, @mem.gb(bytes), delta
21
28
 
22
29
  # kb
23
30
  bytes = 1024
24
- assert_equal 1.0, @mem.kb(bytes)
25
- assert_equal 0.0009765625, @mem.mb(bytes)
26
- assert_equal 9.5367431640625e-07, @mem.gb(bytes)
31
+ assert_in_delta 1.0, @mem.kb(bytes), delta
32
+ assert_in_delta 0.0009765625, @mem.mb(bytes), delta
33
+ assert_in_delta 9.5367431640625e-07, @mem.gb(bytes), delta
27
34
 
28
35
  # mb
29
36
  bytes = 1_048_576
30
- assert_equal 1024.0, @mem.kb(bytes)
31
- assert_equal 1.0, @mem.mb(bytes)
32
- assert_equal 0.0009765625, @mem.gb(bytes)
37
+ assert_in_delta 1024.0, @mem.kb(bytes), delta
38
+ assert_in_delta 1.0, @mem.mb(bytes), delta
39
+ assert_in_delta 0.0009765625, @mem.gb(bytes), delta
33
40
 
34
41
  # gb
35
42
  bytes = 1_073_741_824
36
- assert_equal 1048576.0, @mem.kb(bytes)
37
- assert_equal 1024.0, @mem.mb(bytes)
38
- assert_equal 1.0, @mem.gb(bytes)
43
+ assert_in_delta 1048576.0, @mem.kb(bytes), delta
44
+ assert_in_delta 1024.0, @mem.mb(bytes), delta
45
+ assert_in_delta 1.0, @mem.gb(bytes), delta
39
46
  end
40
47
  end
@@ -3,3 +3,8 @@ Bundler.require
3
3
  require 'get_process_mem'
4
4
  require 'test/unit'
5
5
 
6
+ def fixture_path(name = nil)
7
+ path = Pathname.new(File.expand_path("../fixtures", __FILE__))
8
+ return path.join(name) if name
9
+ path
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_process_mem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -40,6 +40,7 @@ files:
40
40
  - get_process_mem.gemspec
41
41
  - lib/get_process_mem.rb
42
42
  - lib/get_process_mem/version.rb
43
+ - test/fixtures/heroku-bash-smap
43
44
  - test/get_process_mem_test.rb
44
45
  - test/test_helper.rb
45
46
  homepage: https://github.com/schneems/get_process_mem
@@ -67,5 +68,6 @@ signing_key:
67
68
  specification_version: 4
68
69
  summary: Use GetProcessMem to find out the amount of RAM used by any process
69
70
  test_files:
71
+ - test/fixtures/heroku-bash-smap
70
72
  - test/get_process_mem_test.rb
71
73
  - test/test_helper.rb