get_process_mem 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52264416d05e8d73e6a2d1245f1f9bca7b043fb2
4
- data.tar.gz: 5ea9ced69283b2a9e0ea07f08f9dd7d5e928e707
3
+ metadata.gz: d66e96644c3f8d171fd8533346150dc2a653badc
4
+ data.tar.gz: faaa15b6c510b50ced777bc2163042ac2934b9a6
5
5
  SHA512:
6
- metadata.gz: 7b2446a2c0f9fa8f4c387a5ca82f455b4063874f3516a5615c744a4790eb0e166dcfd03400ac52694fef8f557159f5641377194db6be73e495b01cefa4413ccf
7
- data.tar.gz: 98d55d7547d8c73e5d87ed91012df5672abc44d71a5b2853d60f0a6fbdead3d6530bbc8891b026361e48856f6c5f8fd39e5c9ae25fa64a9f19536c51b2d7f5be
6
+ metadata.gz: 03f334783b312689fa9f7adcb28cd692285a2ffe181ebd5753662cb6b8b326249a57391beeea26a0198eddc2c86d8692f20bd70a02d8ab67c1d45be8bd6fc78d
7
+ data.tar.gz: 865fba383f18073a1bf9d7d9cfa543ad56e57544347aa3e8374899aea1f4144a8ddc7b66dc22f2762e94a55ce04970a5d9c865395577436058791bedaa87673a
@@ -1,4 +1,9 @@
1
+ ## 0.2.0
2
+
3
+ - Reverting back to RSS for linux until (#7) is resolved
4
+
1
5
  ## 0.1.1
6
+
2
7
  - Bugfix: the `ps` style of memory reporting should always use RSS, and Linux should always use PSS
3
8
 
4
9
  ## 0.1.0
@@ -53,19 +53,19 @@ class GetProcessMem
53
53
 
54
54
  # linux stores memory info in a file "/proc/#{pid}/smaps"
55
55
  # If it's available it uses less resources than shelling out to ps
56
- # It also allows us to use Pss (the process' proportional share of
57
- # the mapping that is resident in RAM) as mem_type
58
56
  def linux_memory(file = @process_file)
59
- lines = file.each_line.select {|line| line.match /^Pss/ }
57
+ lines = file.each_line.select {|line| line.match /^Rss/ }
60
58
  return if lines.empty?
61
59
  lines.reduce(0) do |sum, line|
62
60
  line.match(/(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/) do |m|
63
61
  value = BigDecimal.new(m[:value]) + ROUND_UP
64
62
  unit = m[:unit].downcase
65
- sum += CONVERSION[unit] * value
63
+ sum += CONVERSION[unit] * value
66
64
  end
67
65
  sum
68
66
  end
67
+ rescue Errno::EACCES
68
+ 0
69
69
  end
70
70
 
71
71
  private
@@ -76,5 +76,3 @@ class GetProcessMem
76
76
  KB_TO_BYTE * BigDecimal.new(`ps -o rss= -p #{pid}`)
77
77
  end
78
78
  end
79
-
80
- GetProcessMem
@@ -1,3 +1,3 @@
1
1
  class GetProcessMem
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -16,7 +16,7 @@ class GetProcessMemTest < Test::Unit::TestCase
16
16
  def test_linux_smap
17
17
  delta = 1
18
18
  bytes = @mem.linux_memory(fixture_path("heroku-bash-smap"))
19
- assert_in_delta BigDecimal.new("1217024.0"), bytes, delta
19
+ assert_in_delta BigDecimal.new("2122240.0"), bytes, delta
20
20
  end
21
21
 
22
22
  def test_conversions
@@ -44,4 +44,4 @@ class GetProcessMemTest < Test::Unit::TestCase
44
44
  assert_in_delta 1024.0, @mem.mb(bytes), delta
45
45
  assert_in_delta 1.0, @mem.gb(bytes), delta
46
46
  end
47
- end
47
+ 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.1
4
+ version: 0.2.0
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-05 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -71,3 +71,4 @@ test_files:
71
71
  - test/fixtures/heroku-bash-smap
72
72
  - test/get_process_mem_test.rb
73
73
  - test/test_helper.rb
74
+ has_rdoc: