memory 0.2.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: d0feb44dbfa1bf04a279604fb651dc730c03fadfcfda51e0818b08d1d590b4a0
4
- data.tar.gz: eb5371436c2c66246d5bdb55a879b3da29c619d20f6a1bfef4a5802000db0a70
3
+ metadata.gz: 37c553347c5941efab19b0f3df37824d10193cbf138582cfc5d24a598ba5a850
4
+ data.tar.gz: edac25b5c09088fabde46d7af1cc5603897d26d5543b3c8b49adea9a92ef6c68
5
5
  SHA512:
6
- metadata.gz: b993009c31964ca15a4ee65f621ec656b3fea7e82b184a8e33b0f0e3163d47947295b0506300e83ff0fc1072e03f071a14a0e26b70d08e8f86760d7a8e1bc993
7
- data.tar.gz: 6167b0aeee0a0f2cb0aba05280b6379d407af895571d28a63921991051e7ba064d5775a5f43aa88b02929dc2582f0688dfe75ec02407e1be7f856f5cb39a26e1
6
+ metadata.gz: 69d25c208346c039acf4c7b190c9b9eece09e7f6fc970db1d4191ed384d2cd74b0650f1c5e69d744e8a1344021c39945d0e21604706887d8495a3f719682bbf9
7
+ data.tar.gz: 0d5d16c7def274988e920930c181e6abf0d5d32b60489d24d95d35b6fc9faa71e4cf285524246a53c3eb9ec589a6892af7685b52a3d320f933a130c0ca1f1553
checksums.yaml.gz.sig ADDED
Binary file
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # @parameter paths [Array(String)] The paths which contain the memory profiles.
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2018, by Sam Saffron.
5
+ # Copyright, 2014, by Richard Schneeman.
6
+ # Copyright, 2018, by Jonas Peschla.
7
+ # Copyright, 2020-2022, by Samuel Williams.
8
+
4
9
  def check(paths:)
5
10
  require 'console'
6
11
 
@@ -31,4 +36,4 @@ def check(paths:)
31
36
  end
32
37
 
33
38
  report.print($stdout)
34
- end
39
+ end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2022, by Samuel Williams.
22
5
 
23
6
  module Memory
24
7
  UNITS = {
@@ -59,6 +42,13 @@ module Memory
59
42
  def to_s
60
43
  "(#{Memory.formatted_bytes memory} in #{count} allocations)"
61
44
  end
45
+
46
+ def as_json
47
+ {
48
+ memory: memory,
49
+ count: count
50
+ }
51
+ end
62
52
  end
63
53
 
64
54
  def initialize(title, &block)
@@ -69,7 +59,10 @@ module Memory
69
59
  @totals = Hash.new{|h,k| h[k] = Total.new}
70
60
  end
71
61
 
62
+ attr :title
63
+ attr :metric
72
64
  attr :total
65
+ attr :totals
73
66
 
74
67
  def << allocation
75
68
  metric = @metric.call(allocation)
@@ -95,6 +88,14 @@ module Memory
95
88
 
96
89
  io.puts nil
97
90
  end
91
+
92
+ def as_json
93
+ {
94
+ title: @title,
95
+ total: @total.as_json,
96
+ totals: @totals.map{|k, v| [k, v.as_json]}
97
+ }
98
+ end
98
99
  end
99
100
 
100
101
  class ValueAggregate
@@ -105,6 +106,10 @@ module Memory
105
106
  @aggregates = Hash.new{|h,k| h[k] = Aggregate.new(k.inspect, &@metric)}
106
107
  end
107
108
 
109
+ attr :title
110
+ attr :metric
111
+ attr :aggregates
112
+
108
113
  def << allocation
109
114
  if value = allocation.value
110
115
  aggregate = @aggregates[value]
@@ -124,5 +129,12 @@ module Memory
124
129
  aggregate.print(io, level: level+1)
125
130
  end
126
131
  end
132
+
133
+ def as_json
134
+ {
135
+ title: @title,
136
+ aggregates: @aggregates.map{|k, v| [k, v.as_json]}
137
+ }
138
+ end
127
139
  end
128
140
  end
data/lib/memory/cache.rb CHANGED
@@ -1,24 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2020, by Sam Saffron.
5
+ # Copyright, 2015-2018, by Dave Gynn.
6
+ # Copyright, 2015, by Vincent Woo.
7
+ # Copyright, 2015, by Boris Staal.
8
+ # Copyright, 2016, by Hamdi Akoğuz.
9
+ # Copyright, 2018, by Jonas Peschla.
10
+ # Copyright, 2020, by Jean Boussier.
11
+ # Copyright, 2020-2022, by Samuel Williams.
22
12
 
23
13
  module Memory
24
14
  class Cache
data/lib/memory/deque.rb CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2022, by Samuel Williams.
22
5
 
23
6
  require 'objspace'
24
7
  require 'msgpack'
data/lib/memory/report.rb CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2022, by Samuel Williams.
22
5
 
23
6
  require_relative 'aggregate'
24
7
 
@@ -66,5 +49,17 @@ module Memory
66
49
  aggregate.print(io)
67
50
  end
68
51
  end
52
+
53
+ def as_json
54
+ {
55
+ total_allocated: @total_allocated.as_json,
56
+ total_retained: @total_retained.as_json,
57
+ aggregates: @aggregates.map(&:as_json)
58
+ }
59
+ end
60
+
61
+ def to_json(...)
62
+ as_json.to_json(...)
63
+ end
69
64
  end
70
65
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2022, by Samuel Williams.
22
5
 
23
6
  require_relative '../sampler'
24
7
 
@@ -1,24 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2020, by Sam Saffron.
5
+ # Copyright, 2014, by Richard Schneeman.
6
+ # Copyright, 2014, by Søren Skovsbøll.
7
+ # Copyright, 2015, by Anton Davydov.
8
+ # Copyright, 2015-2018, by Dave Gynn.
9
+ # Copyright, 2017, by Nick LaMuro.
10
+ # Copyright, 2018, by William Tabi.
11
+ # Copyright, 2018, by Jonas Peschla.
12
+ # Copyright, 2018, by Espartaco Palma.
13
+ # Copyright, 2020, by Jean Boussier.
14
+ # Copyright, 2020-2022, by Samuel Williams.
22
15
 
23
16
  require 'objspace'
24
17
  require 'msgpack'
@@ -1,25 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2019, by Sam Saffron.
5
+ # Copyright, 2015-2016, by Dave Gynn.
6
+ # Copyright, 2018, by Jonas Peschla.
7
+ # Copyright, 2020-2022, by Samuel Williams.
22
8
 
23
9
  module Memory
24
- VERSION = "0.2.0"
10
+ VERSION = "0.3.0"
25
11
  end
data/lib/memory.rb CHANGED
@@ -1,24 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2019, by Sam Saffron.
5
+ # Copyright, 2014, by Søren Skovsbøll.
6
+ # Copyright, 2017, by Nick LaMuro.
7
+ # Copyright, 2018, by Jonas Peschla.
8
+ # Copyright, 2020-2022, by Samuel Williams.
22
9
 
23
10
  require_relative "memory/version"
24
11
  require_relative "memory/cache"
data/license.md ADDED
@@ -0,0 +1,45 @@
1
+ # MIT License
2
+
3
+ Copyright, 2013-2020, by Sam Saffron.
4
+ Copyright, 2013, by Luís Ferreira.
5
+ Copyright, 2014, by John Bachir.
6
+ Copyright, 2014, by Andrew Grimm.
7
+ Copyright, 2014, by Richard Schneeman.
8
+ Copyright, 2014, by Jaiden Mispy.
9
+ Copyright, 2014, by Søren Skovsbøll.
10
+ Copyright, 2015, by Anton Davydov.
11
+ Copyright, 2015, by Mike Subelsky.
12
+ Copyright, 2015, by Florian Schwab.
13
+ Copyright, 2015-2018, by Dave Gynn.
14
+ Copyright, 2015, by Vincent Woo.
15
+ Copyright, 2015, by Boris Staal.
16
+ Copyright, 2016, by Hamdi Akoğuz.
17
+ Copyright, 2017, by Nick LaMuro.
18
+ Copyright, 2017, by Vasily Kolesnikov.
19
+ Copyright, 2018, by William Tabi.
20
+ Copyright, 2018, by Jonas Peschla.
21
+ Copyright, 2018, by Benoit Tigeot.
22
+ Copyright, 2018, by Espartaco Palma.
23
+ Copyright, 2019-2020, by Jean Boussier.
24
+ Copyright, 2019, by Ashwin Maroli.
25
+ Copyright, 2019, by Olle Jonsson.
26
+ Copyright, 2019, by Danny Ben Shitrit.
27
+ Copyright, 2020-2022, by Samuel Williams.
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all
37
+ copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,123 @@
1
+ # Memory
2
+
3
+ A set of tools for profiling memory in Ruby.
4
+
5
+ [![Development Status](https://github.com/socketry/memory/workflows/Test/badge.svg)](https://github.com/socketry/memory/actions?workflow=Test)
6
+
7
+ ## Features
8
+
9
+ - Fast memory capture for million+ allocations.
10
+ - Persist results to disk for vast aggregations and comparisons over time.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ``` shell
17
+ $ bundle add 'memory'
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ``` ruby
23
+ require 'memory'
24
+
25
+ report = Memory.report do
26
+ # run your code here
27
+ end
28
+
29
+ report.print
30
+ ```
31
+
32
+ Or, you can use the `.start`/`.stop` methods as well:
33
+
34
+ ``` ruby
35
+ require 'memory'
36
+
37
+ sampler = Memory::Sampler.new
38
+
39
+ sampler.start
40
+ # run your code here
41
+ sampler.stop
42
+
43
+ report = sampler.report
44
+ report.print
45
+ ```
46
+
47
+ ### RSpec Integration
48
+
49
+ ``` ruby
50
+ memory_sampler = nil
51
+ config.before(:all) do |example_group|
52
+ name = example_group.class.description.gsub(/[^\w]+/, "-")
53
+ path = "#{name}.mprof"
54
+
55
+ skip if File.exist?(path)
56
+
57
+ memory_sampler = Memory::Sampler.new
58
+ memory_sampler.start
59
+ end
60
+
61
+ config.after(:all) do |example_group|
62
+ name = example_group.class.description.gsub(/[^\w]+/, "-")
63
+ path = "#{name}.mprof"
64
+
65
+ if memory_sampler
66
+ memory_sampler.stop
67
+
68
+ File.open(path, "w", encoding: Encoding::BINARY) do |io|
69
+ memory_sampler.dump(io)
70
+ end
71
+
72
+ memory_sampler = nil
73
+ end
74
+ end
75
+
76
+ config.after(:suite) do
77
+ memory_sampler = Memory::Sampler.new
78
+
79
+ Dir.glob("*.mprof") do |path|
80
+ memory_sampler.load(File.read(
81
+ path,
82
+ encoding: Encoding::BINARY,
83
+ ))
84
+ end
85
+
86
+ memory_sampler.results.print
87
+ end
88
+ ```
89
+
90
+ #### Raw Object Allocations
91
+
92
+ ``` ruby
93
+ before = nil
94
+
95
+ config.before(:suite) do |example|
96
+ 3.times{GC.start}
97
+ GC.disable
98
+ before = ObjectSpace.count_objects
99
+ end
100
+
101
+ config.after(:suite) do |example|
102
+ after = ObjectSpace.count_objects
103
+ GC.enable
104
+
105
+ $stderr.puts
106
+ $stderr.puts "Object Allocations:"
107
+
108
+ after.each do |key, b|
109
+ a = before.fetch(key, 0)
110
+ $stderr.puts "#{key}: #{a} -> #{b} = #{b-a} allocations"
111
+ end
112
+ end
113
+ ```
114
+
115
+ ## Contributing
116
+
117
+ We welcome contributions to this project.
118
+
119
+ 1. Fork it.
120
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
121
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
122
+ 4. Push to the branch (`git push origin my-new-feature`).
123
+ 5. Create new Pull Request.
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,18 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Samuel Williams
8
7
  - Sam Saffron
8
+ - Dave Gynn
9
+ - Nick LaMuro
10
+ - Jonas Peschla
11
+ - Samuel Williams
12
+ - Ashwin Maroli
13
+ - Søren Skovsbøll
14
+ - Richard Schneeman
15
+ - Anton Davydov
16
+ - Benoit Tigeot
17
+ - Jean Boussier
18
+ - Vincent Woo
19
+ - Andrew Grimm
20
+ - Boris Staal
21
+ - Danny Ben Shitrit
22
+ - Espartaco Palma
23
+ - Florian Schwab
24
+ - Hamdi Akoğuz
25
+ - Jaiden Mispy
26
+ - John Bachir
27
+ - Luís Ferreira
28
+ - Mike Subelsky
29
+ - Olle Jonsson
30
+ - Vasily Kolesnikov
31
+ - William Tabi
9
32
  autorequire:
10
33
  bindir: bin
11
- cert_chain: []
12
- date: 2020-11-05 00:00:00.000000000 Z
34
+ cert_chain:
35
+ - |
36
+ -----BEGIN CERTIFICATE-----
37
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
38
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
39
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
40
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
41
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
42
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
43
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
44
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
45
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
46
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
47
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
48
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
49
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
50
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
51
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
52
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
53
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
54
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
55
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
56
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
57
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
58
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
59
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
60
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
61
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
62
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
63
+ -----END CERTIFICATE-----
64
+ date: 2022-11-15 00:00:00.000000000 Z
13
65
  dependencies:
14
66
  - !ruby/object:Gem::Dependency
15
- name: msgpack
67
+ name: bake
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.15'
73
+ type: :runtime
74
+ prerelease: false
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.15'
80
+ - !ruby/object:Gem::Dependency
81
+ name: console
16
82
  requirement: !ruby/object:Gem::Requirement
17
83
  requirements:
18
84
  - - ">="
@@ -26,7 +92,7 @@ dependencies:
26
92
  - !ruby/object:Gem::Version
27
93
  version: '0'
28
94
  - !ruby/object:Gem::Dependency
29
- name: console
95
+ name: msgpack
30
96
  requirement: !ruby/object:Gem::Requirement
31
97
  requirements:
32
98
  - - ">="
@@ -40,19 +106,19 @@ dependencies:
40
106
  - !ruby/object:Gem::Version
41
107
  version: '0'
42
108
  - !ruby/object:Gem::Dependency
43
- name: bake
109
+ name: bake-test
44
110
  requirement: !ruby/object:Gem::Requirement
45
111
  requirements:
46
- - - "~>"
112
+ - - ">="
47
113
  - !ruby/object:Gem::Version
48
- version: 0.15.0
49
- type: :runtime
114
+ version: '0'
115
+ type: :development
50
116
  prerelease: false
51
117
  version_requirements: !ruby/object:Gem::Requirement
52
118
  requirements:
53
- - - "~>"
119
+ - - ">="
54
120
  - !ruby/object:Gem::Version
55
- version: 0.15.0
121
+ version: '0'
56
122
  - !ruby/object:Gem::Dependency
57
123
  name: bundler
58
124
  requirement: !ruby/object:Gem::Requirement
@@ -82,19 +148,19 @@ dependencies:
82
148
  - !ruby/object:Gem::Version
83
149
  version: '0'
84
150
  - !ruby/object:Gem::Dependency
85
- name: rspec
151
+ name: sus
86
152
  requirement: !ruby/object:Gem::Requirement
87
153
  requirements:
88
- - - "~>"
154
+ - - ">="
89
155
  - !ruby/object:Gem::Version
90
- version: '3.0'
156
+ version: '0'
91
157
  type: :development
92
158
  prerelease: false
93
159
  version_requirements: !ruby/object:Gem::Requirement
94
160
  requirements:
95
- - - "~>"
161
+ - - ">="
96
162
  - !ruby/object:Gem::Version
97
- version: '3.0'
163
+ version: '0'
98
164
  description:
99
165
  email:
100
166
  executables: []
@@ -110,6 +176,8 @@ files:
110
176
  - lib/memory/rspec/profiler.rb
111
177
  - lib/memory/sampler.rb
112
178
  - lib/memory/version.rb
179
+ - license.md
180
+ - readme.md
113
181
  homepage: https://github.com/socketry/memory
114
182
  licenses:
115
183
  - MIT
@@ -129,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
197
  - !ruby/object:Gem::Version
130
198
  version: '0'
131
199
  requirements: []
132
- rubygems_version: 3.0.3
200
+ rubygems_version: 3.3.7
133
201
  signing_key:
134
202
  specification_version: 4
135
203
  summary: Memory profiling routines for Ruby 2.3+
metadata.gz.sig ADDED
Binary file