busy-administrator 1.0.0 → 1.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 028975af3001dec517754873ef39df4df057b97f
|
4
|
+
data.tar.gz: 4b79d312d9a12f12a0bebb1f23c67a5d3917f4be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4f27c38524312770087828fb57fdf4556f5254a547bf4e0c9d42e2ec43cef94cbd57c2d172b716087b4ba1205c97d75cedc5b4d99c2324ac8bdb3c00405cdd3
|
7
|
+
data.tar.gz: a75c84f74e463cc7631967d3a3f13474db460b4093e8eb3c0fa4683b78c9ca7b1de8bd8d7b4417b48d1fb307a82b1bc30692b5f58e6ad0c619ecf981fab11223
|
data/lib/busy-administrator.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
module BusyAdministrator
|
2
|
+
class MemoryMiddleware
|
3
|
+
module Analyzer
|
4
|
+
def analyze(key:, value:)
|
5
|
+
if analyzer = request.env['busy-administrator-analyzer']
|
6
|
+
analyzer.include(key: key, value: value)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(app)
|
12
|
+
@app = app
|
13
|
+
end
|
14
|
+
|
15
|
+
def assets_request?(env)
|
16
|
+
env['PATH_INFO'].ends_with?('.js') || env['PATH_INFO'].ends_with?('.css')
|
17
|
+
end
|
18
|
+
|
19
|
+
def enabled?
|
20
|
+
ENV['BUSY_ADMINISTRATOR_PROFILE'] == "YES"
|
21
|
+
end
|
22
|
+
|
23
|
+
def disabled?
|
24
|
+
not enabled?
|
25
|
+
end
|
26
|
+
|
27
|
+
def gc_enabled?
|
28
|
+
ENV['BUSY_ADMINISTRATOR_GC_ENABLED'] == "YES"
|
29
|
+
end
|
30
|
+
|
31
|
+
def call(env)
|
32
|
+
response = nil
|
33
|
+
|
34
|
+
if assets_request?(env) || disabled?
|
35
|
+
response = @app.call(env)
|
36
|
+
else
|
37
|
+
results = BusyAdministrator::MemoryUtils.profile(gc_enabled: gc_enabled?) do |analyzer|
|
38
|
+
env['busy-administrator-analyzer'] = analyzer
|
39
|
+
|
40
|
+
response = @app.call(env)
|
41
|
+
end
|
42
|
+
|
43
|
+
BusyAdministrator::Display.debug(results)
|
44
|
+
end
|
45
|
+
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -82,7 +82,7 @@ module BusyAdministrator
|
|
82
82
|
excluded_object_id_storage = get_created_object_ids
|
83
83
|
log("[Before] Object Count: #{ excluded_object_id_storage.size }", verbose: verbose)
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
action("Get Memory Usage Before Execution") do
|
87
87
|
memory_usage_before = ProcessUtils.get_memory_usage(:rss)
|
88
88
|
output_container[:memory_usage][:before] = memory_usage_before
|
@@ -147,11 +147,12 @@ module BusyAdministrator
|
|
147
147
|
general = {}
|
148
148
|
|
149
149
|
all_object_ids_after_execution.each do |object_id|
|
150
|
-
target = ObjectSpace._id2ref(object_id)
|
151
|
-
target_class = target.class.name
|
150
|
+
target = ObjectSpace._id2ref(object_id) rescue nil
|
152
151
|
|
153
|
-
|
154
|
-
|
152
|
+
if target_class = target.class.name rescue nil
|
153
|
+
general[target_class.to_sym] ||= 0
|
154
|
+
general[target_class.to_sym] += ObjectSpace.memsize_of(target)
|
155
|
+
end
|
155
156
|
end
|
156
157
|
|
157
158
|
general.each do |key, value|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: busy-administrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Arvin Lat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09
|
11
|
+
date: 2016-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/busy-administrator.rb
|
49
49
|
- lib/busy-administrator/display.rb
|
50
50
|
- lib/busy-administrator/example_generator.rb
|
51
|
+
- lib/busy-administrator/memory_middleware.rb
|
51
52
|
- lib/busy-administrator/memory_size.rb
|
52
53
|
- lib/busy-administrator/memory_utils.rb
|
53
54
|
- lib/busy-administrator/process_utils.rb
|