memory 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bake/memory/profiler.rb +3 -6
- data/lib/memory/rspec/profiler.rb +71 -0
- data/lib/memory/version.rb +1 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0feb44dbfa1bf04a279604fb651dc730c03fadfcfda51e0818b08d1d590b4a0
|
4
|
+
data.tar.gz: eb5371436c2c66246d5bdb55a879b3da29c619d20f6a1bfef4a5802000db0a70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b993009c31964ca15a4ee65f621ec656b3fea7e82b184a8e33b0f0e3163d47947295b0506300e83ff0fc1072e03f071a14a0e26b70d08e8f86760d7a8e1bc993
|
7
|
+
data.tar.gz: 6167b0aeee0a0f2cb0aba05280b6379d407af895571d28a63921991051e7ba064d5775a5f43aa88b02929dc2582f0688dfe75ec02407e1be7f856f5cb39a26e1
|
data/bake/memory/profiler.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
# @parameter paths [Array(String)] The paths which contain the memory profiles.
|
4
|
+
def check(paths:)
|
4
5
|
require 'console'
|
5
6
|
|
6
|
-
paths = Dir["../../*.mprof"]
|
7
|
-
|
8
7
|
total_size = paths.sum{|path| File.size(path)}
|
9
8
|
|
10
|
-
require_relative 'lib/
|
9
|
+
require_relative '../../lib/memory'
|
11
10
|
|
12
11
|
report = Memory::Report.general
|
13
12
|
|
@@ -32,6 +31,4 @@ def check
|
|
32
31
|
end
|
33
32
|
|
34
33
|
report.print($stdout)
|
35
|
-
|
36
|
-
binding.irb
|
37
34
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
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.
|
22
|
+
|
23
|
+
require_relative '../sampler'
|
24
|
+
|
25
|
+
module Memory
|
26
|
+
module RSpec
|
27
|
+
module Profiler
|
28
|
+
def self.profile(scope)
|
29
|
+
memory_sampler = nil
|
30
|
+
|
31
|
+
scope.before(:all) do |example_group|
|
32
|
+
name = example_group.class.description.gsub(/[^\w]+/, "-")
|
33
|
+
path = "#{name}.mprof"
|
34
|
+
|
35
|
+
skip if File.exist?(path)
|
36
|
+
|
37
|
+
memory_sampler = Memory::Sampler.new
|
38
|
+
memory_sampler.start
|
39
|
+
end
|
40
|
+
|
41
|
+
scope.after(:all) do |example_group|
|
42
|
+
name = example_group.class.description.gsub(/[^\w]+/, "-")
|
43
|
+
path = "#{name}.mprof"
|
44
|
+
|
45
|
+
if memory_sampler
|
46
|
+
memory_sampler.stop
|
47
|
+
|
48
|
+
File.open(path, "w", encoding: Encoding::BINARY) do |io|
|
49
|
+
memory_sampler.dump(io)
|
50
|
+
end
|
51
|
+
|
52
|
+
memory_sampler = nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
scope.after(:suite) do
|
57
|
+
memory_sampler = Memory::Sampler.new
|
58
|
+
|
59
|
+
Dir.glob("*.mprof") do |path|
|
60
|
+
memory_sampler.load(File.read(
|
61
|
+
path,
|
62
|
+
encoding: Encoding::BINARY,
|
63
|
+
))
|
64
|
+
end
|
65
|
+
|
66
|
+
memory_sampler.report.print
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/memory/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
@@ -25,6 +25,34 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: console
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.15.0
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.15.0
|
28
56
|
- !ruby/object:Gem::Dependency
|
29
57
|
name: bundler
|
30
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,6 +107,7 @@ files:
|
|
79
107
|
- lib/memory/cache.rb
|
80
108
|
- lib/memory/deque.rb
|
81
109
|
- lib/memory/report.rb
|
110
|
+
- lib/memory/rspec/profiler.rb
|
82
111
|
- lib/memory/sampler.rb
|
83
112
|
- lib/memory/version.rb
|
84
113
|
homepage: https://github.com/socketry/memory
|