droid-monitor 0.6.1 → 0.7.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.
@@ -1,8 +1,10 @@
1
- require_relative "../monitor"
2
- require_relative "common/commons"
3
- require_relative "report/google_api_template"
1
+ # frozen_string_literal: true
4
2
 
5
- require "json"
3
+ require_relative '../monitor'
4
+ require_relative 'common/commons'
5
+ require_relative 'report/google_api_template'
6
+
7
+ require 'json'
6
8
 
7
9
  module Droid
8
10
  module Monitor
@@ -49,20 +51,20 @@ module Droid
49
51
 
50
52
  # called directory
51
53
  def store_dumped_gfxinfo_usage
52
- self.store_gfxinfo_usage(self.dump_gfxinfo_usage(self.dump_gfxinfo))
54
+ store_gfxinfo_usage(dump_gfxinfo_usage(dump_gfxinfo))
53
55
  end
54
56
 
55
57
  # @param [String] file_path_gfx A file path to save gfx data.
56
58
  # @param [String] file_path_mem A file path to save memory usage regarding gfx data.
57
59
  # @param [String] file_path_frame A file path to save frame data.
58
60
  def save_gfxinfo_usage_as_google_api(file_path_gfx, file_path_mem, file_path_frame)
59
- self.save(export_as_google_api_format_gfx(@gfxinfo_usage), file_path_gfx)
60
- self.save(export_as_google_api_format_mem(@gfxinfo_usage), file_path_mem)
61
- self.save(export_as_google_api_format_frame(@gfxinfo_usage), file_path_frame)
61
+ save(export_as_google_api_format_gfx(@gfxinfo_usage), file_path_gfx)
62
+ save(export_as_google_api_format_mem(@gfxinfo_usage), file_path_mem)
63
+ save(export_as_google_api_format_frame(@gfxinfo_usage), file_path_frame)
62
64
  end
63
65
 
64
66
  def store_gfxinfo_usage(dumped_gfxinfo)
65
- @gfxinfo_usage.push self.merge_current_time(transfer_total_gfxinfo_to_hash(dumped_gfxinfo))
67
+ @gfxinfo_usage.push merge_current_time(transfer_total_gfxinfo_to_hash(dumped_gfxinfo))
66
68
  end
67
69
 
68
70
  def transfer_total_gfxinfo_to_hash(dump_gfxinfo_array)
@@ -72,7 +74,7 @@ module Droid
72
74
  display_lists_kb: 0,
73
75
  frames_rendered: 0,
74
76
  total_memory: 0,
75
- time: dump_gfxinfo_array.last,
77
+ time: dump_gfxinfo_array.last
76
78
  }
77
79
  elsif @api_level >= 23
78
80
  {
@@ -81,15 +83,15 @@ module Droid
81
83
  frames_rendered: dump_gfxinfo_array[14].to_i || 0,
82
84
  janky_frame: dump_gfxinfo_array[17].to_i || 0,
83
85
  total_memory: (dump_gfxinfo_array[0].to_f / 1024).round(2),
84
- time: dump_gfxinfo_array.last,
86
+ time: dump_gfxinfo_array.last
85
87
  }
86
88
  else
87
89
  {
88
- view: dump_gfxinfo_array[4].to_i,
89
- display_lists_kb: dump_gfxinfo_array[6].to_f.round(2),
90
- frames_rendered: dump_gfxinfo_array[11].to_i || 0,
91
- total_memory: (dump_gfxinfo_array[0].to_f / 1024).round(2),
92
- time: dump_gfxinfo_array.last,
90
+ view: dump_gfxinfo_array[4].to_i,
91
+ display_lists_kb: dump_gfxinfo_array[6].to_f.round(2),
92
+ frames_rendered: dump_gfxinfo_array[11].to_i || 0,
93
+ total_memory: (dump_gfxinfo_array[0].to_f / 1024).round(2),
94
+ time: dump_gfxinfo_array.last
93
95
  }
94
96
  end
95
97
  end
@@ -102,7 +104,7 @@ module Droid
102
104
  c: [
103
105
  { v: hash[:time] },
104
106
  { v: hash[:view] },
105
- { v: hash[:display_lists_kb] },
107
+ { v: hash[:display_lists_kb] }
106
108
  ]
107
109
  }
108
110
  google_api_data_format[:rows].push(a_google_api_data_format)
@@ -118,7 +120,7 @@ module Droid
118
120
  a_google_api_data_format = {
119
121
  c: [
120
122
  { v: hash[:time] },
121
- { v: hash[:total_memory] },
123
+ { v: hash[:total_memory] }
122
124
  ]
123
125
  }
124
126
  google_api_data_format[:rows].push(a_google_api_data_format)
@@ -133,21 +135,21 @@ module Droid
133
135
  if @api_level >= 23
134
136
  from_gfxinfo_usage.each do |hash|
135
137
  a_google_api_data_format = {
136
- c: [
137
- { v: hash[:time] },
138
- { v: hash[:frames_rendered] },
139
- { v: hash[:janky_frame] },
140
- ]
138
+ c: [
139
+ { v: hash[:time] },
140
+ { v: hash[:frames_rendered] },
141
+ { v: hash[:janky_frame] }
142
+ ]
141
143
  }
142
144
  google_api_data_format[:rows].push(a_google_api_data_format)
143
145
  end
144
146
  else
145
147
  from_gfxinfo_usage.each do |hash|
146
148
  a_google_api_data_format = {
147
- c: [
148
- { v: hash[:time] },
149
- { v: hash[:frames_rendered] },
150
- ]
149
+ c: [
150
+ { v: hash[:time] },
151
+ { v: hash[:frames_rendered] }
152
+ ]
151
153
  }
152
154
  google_api_data_format[:rows].push(a_google_api_data_format)
153
155
  end
@@ -155,9 +157,9 @@ module Droid
155
157
  JSON.generate google_api_data_format
156
158
  end
157
159
 
158
- def create_graph(data_file_path, graph_opts = {}, output_file_path)
159
- self.save(Droid::Monitor::GoogleApiTemplate.create_graph(data_file_path, graph_opts),
160
- output_file_path)
160
+ def create_graph(data_file_path, graph_opts = {}, output_file_path) # rubocop:disable Style/OptionalArguments
161
+ save(Droid::Monitor::GoogleApiTemplate.create_graph(data_file_path, graph_opts),
162
+ output_file_path)
161
163
  end
162
164
 
163
165
  private
@@ -167,10 +169,9 @@ module Droid
167
169
  cols: [
168
170
  { label: 'time', type: 'string' },
169
171
  { label: 'view', type: 'number' },
170
- { label: 'display_lists_kb', type: 'number' },
171
- ],
172
- rows: [
172
+ { label: 'display_lists_kb', type: 'number' }
173
173
  ],
174
+ rows: []
174
175
  }
175
176
  end
176
177
 
@@ -178,10 +179,9 @@ module Droid
178
179
  {
179
180
  cols: [
180
181
  { label: 'time', type: 'string' },
181
- { label: 'total_memory', type: 'number' },
182
- ],
183
- rows: [
182
+ { label: 'total_memory', type: 'number' }
184
183
  ],
184
+ rows: []
185
185
  }
186
186
  end
187
187
 
@@ -191,19 +191,17 @@ module Droid
191
191
  cols: [
192
192
  { label: 'time', type: 'string' },
193
193
  { label: 'frames_rendered', type: 'number' },
194
- { label: 'janky_frame', type: 'number' },
195
- ],
196
- rows: [
194
+ { label: 'janky_frame', type: 'number' }
197
195
  ],
196
+ rows: []
198
197
  }
199
198
  else
200
199
  {
201
- cols: [
202
- { label: 'time', type: 'string' },
203
- { label: 'frames_rendered', type: 'number' },
204
- ],
205
- rows: [
206
- ],
200
+ cols: [
201
+ { label: 'time', type: 'string' },
202
+ { label: 'frames_rendered', type: 'number' }
203
+ ],
204
+ rows: []
207
205
  }
208
206
  end
209
207
  end
@@ -1,8 +1,10 @@
1
- require_relative "../monitor"
2
- require_relative "common/commons"
3
- require_relative "report/google_api_template"
1
+ # frozen_string_literal: true
4
2
 
5
- require "json"
3
+ require_relative '../monitor'
4
+ require_relative 'common/commons'
5
+ require_relative 'report/google_api_template'
6
+
7
+ require 'json'
6
8
 
7
9
  module Droid
8
10
  module Monitor
@@ -26,11 +28,12 @@ module Droid
26
28
  end
27
29
 
28
30
  def dump_memory_usage(dump_data)
29
- fail "no process" if dump_data == "No process found for: #{@package}"
31
+ raise 'no process' if dump_data == "No process found for: #{@package}"
30
32
 
31
33
  scanned_dump = dump_data.scan(/^.*Uptime.*Realtime.*$/).map(&:strip).first
32
34
 
33
35
  return [] if scanned_dump.nil?
36
+
34
37
  scanned_dump.split(/\s/).reject(&:empty?)
35
38
  rescue StandardError => e
36
39
  puts e
@@ -38,10 +41,12 @@ module Droid
38
41
  end
39
42
 
40
43
  def dump_memory_details_usage(dump_data)
41
- fail "no process" if dump_data == "No process found for: #{@package}"
44
+ raise 'no process' if dump_data == "No process found for: #{@package}"
45
+
42
46
  scanned_dump = dump_data.scan(/^.*TOTAL.*$/).map(&:strip).first
43
47
 
44
48
  return [] if scanned_dump.nil?
49
+
45
50
  scanned_dump.split(/\s/).reject(&:empty?)
46
51
  rescue StandardError => e
47
52
  puts e
@@ -50,32 +55,32 @@ module Droid
50
55
 
51
56
  # called directory
52
57
  def store_dumped_memory_usage
53
- self.store_memory_usage(self.dump_memory_usage(self.dump_meminfo))
58
+ store_memory_usage(dump_memory_usage(dump_meminfo))
54
59
  end
55
60
 
56
61
  # called directory
57
62
  def store_dumped_memory_details_usage
58
- self.store_memory_details_usage(self.dump_memory_details_usage(self.dump_meminfo))
63
+ store_memory_details_usage(dump_memory_details_usage(dump_meminfo))
59
64
  end
60
65
 
61
66
  def save_memory_as_google_api(file_path)
62
- self.save(export_as_google_api_format(@memory_usage), file_path)
67
+ save(export_as_google_api_format(@memory_usage), file_path)
63
68
  end
64
69
 
65
70
  def save_memory_details_as_google_api(file_path)
66
- self.save(export_as_google_api_format(@memory_detail_usage), file_path)
71
+ save(export_as_google_api_format(@memory_detail_usage), file_path)
67
72
  end
68
73
 
69
74
  # @param [Array] dumped_memory Array of dumped memory data
70
75
  # @return [Hash] Google API formatted data
71
76
  def store_memory_usage(dumped_memory)
72
- @memory_usage.push self.merge_current_time(transfer_total_memory_to_hash(dumped_memory))
77
+ @memory_usage.push merge_current_time(transfer_total_memory_to_hash(dumped_memory))
73
78
  end
74
79
 
75
80
  # @param [Array] dumped_memory_details Array of dumped memory data
76
81
  # @return [Hash] Google API formatted data
77
82
  def store_memory_details_usage(dumped_memory_details)
78
- @memory_detail_usage.push self.merge_current_time(transfer_total_memory_details_to_hash(dumped_memory_details))
83
+ @memory_detail_usage.push merge_current_time(transfer_total_memory_details_to_hash(dumped_memory_details))
79
84
  end
80
85
 
81
86
  def transfer_total_memory_to_hash(data)
@@ -103,12 +108,11 @@ module Droid
103
108
  { v: hash[:swapped_dirty] },
104
109
  { v: hash[:heap_size] },
105
110
  { v: hash[:heap_alloc] },
106
- { v: hash[:heap_free] },
107
- ],
111
+ { v: hash[:heap_free] }
112
+ ]
108
113
  }
109
114
  google_api_data_format[:rows].push(a_google_api_data_format)
110
115
  end
111
- JSON.generate google_api_data_format
112
116
  else
113
117
  google_api_data_format = empty_google_api_format_over43
114
118
 
@@ -121,22 +125,21 @@ module Droid
121
125
  { v: hash[:private_dirty] },
122
126
  { v: hash[:heap_size] },
123
127
  { v: hash[:heap_alloc] },
124
- { v: hash[:heap_free] },
125
- ],
128
+ { v: hash[:heap_free] }
129
+ ]
126
130
  }
127
131
  google_api_data_format[:rows].push(a_google_api_data_format)
128
132
  end
129
-
130
- JSON.generate google_api_data_format
131
133
  end
134
+ JSON.generate google_api_data_format
132
135
  end
133
136
 
134
137
  # @params [String] data_file_path A path to data.
135
138
  # @params [Hash] graph_opts A hash regarding graph settings.
136
139
  # @params [String] output_file_path A path you would like to export data.
137
- def create_graph(data_file_path, graph_opts = {}, output_file_path)
138
- self.save(Droid::Monitor::GoogleApiTemplate.create_graph(data_file_path, graph_opts),
139
- output_file_path)
140
+ def create_graph(data_file_path, graph_opts = {}, output_file_path) # rubocop:disable Style/OptionalArguments
141
+ save(Droid::Monitor::GoogleApiTemplate.create_graph(data_file_path, graph_opts),
142
+ output_file_path)
140
143
  end
141
144
 
142
145
  private
@@ -151,10 +154,9 @@ module Droid
151
154
  { label: 'swapped_dirty', type: 'number' },
152
155
  { label: 'heap_size', type: 'number' },
153
156
  { label: 'heap_alloc', type: 'number' },
154
- { label: 'heap_free', type: 'number' },
155
- ],
156
- rows: [
157
+ { label: 'heap_free', type: 'number' }
157
158
  ],
159
+ rows: []
158
160
  }
159
161
  end
160
162
 
@@ -167,17 +169,16 @@ module Droid
167
169
  { label: 'private_dirty', type: 'number' },
168
170
  { label: 'heap_size', type: 'number' },
169
171
  { label: 'heap_alloc', type: 'number' },
170
- { label: 'heap_free', type: 'number' },
171
- ],
172
- rows: [
172
+ { label: 'heap_free', type: 'number' }
173
173
  ],
174
+ rows: []
174
175
  }
175
176
  end
176
177
 
177
178
  def total_memory(data)
178
179
  {
179
180
  uptime: data[1].to_i ||= 0,
180
- realtime: data[3].to_i ||= 0,
181
+ realtime: data[3].to_i ||= 0
181
182
  }
182
183
  end
183
184
 
@@ -189,7 +190,7 @@ module Droid
189
190
  swapped_dirty: data[4].to_i ||= 0,
190
191
  heap_size: data[5].to_i ||= 0,
191
192
  heap_alloc: data[6].to_i ||= 0,
192
- heap_free: data[7].to_i ||= 0,
193
+ heap_free: data[7].to_i ||= 0
193
194
  }
194
195
  end
195
196
 
@@ -200,10 +201,9 @@ module Droid
200
201
  private_dirty: data[3].to_i ||= 0,
201
202
  heap_size: data[4].to_i ||= 0,
202
203
  heap_alloc: data[5].to_i ||= 0,
203
- heap_free: data[6].to_i ||= 0,
204
+ heap_free: data[6].to_i ||= 0
204
205
  }
205
206
  end
206
-
207
207
  end # class Memory
208
208
  end # module Monitor
209
209
  end # module Droid
@@ -1,8 +1,10 @@
1
- require_relative "../monitor"
2
- require_relative "common/commons"
3
- require_relative "report/google_api_template"
1
+ # frozen_string_literal: true
4
2
 
5
- require "json"
3
+ require_relative '../monitor'
4
+ require_relative 'common/commons'
5
+ require_relative 'report/google_api_template'
6
+
7
+ require 'json'
6
8
 
7
9
  module Droid
8
10
  module Monitor
@@ -40,27 +42,27 @@ module Droid
40
42
 
41
43
  # called directory
42
44
  def store_dumped_tcp_rec
43
- self.store_tcp_rec(self.dump_tcp_rec_usage(self.dump_tcp_rec))
45
+ store_tcp_rec(dump_tcp_rec_usage(dump_tcp_rec))
44
46
  end
45
47
 
46
48
  def store_dumped_tcp_snd
47
- self.store_tcp_snd(self.dump_tcp_snd_usage(self.dump_tcp_snd))
49
+ store_tcp_snd(dump_tcp_snd_usage(dump_tcp_snd))
48
50
  end
49
51
 
50
52
  def save_cpu_usage_as_google_api_rec(file_path)
51
- self.save(export_as_google_api_format_rec(@tcp_rec), file_path)
53
+ save(export_as_google_api_format_rec(@tcp_rec), file_path)
52
54
  end
53
55
 
54
56
  def save_cpu_usage_as_google_api_snd(file_path)
55
- self.save(export_as_google_api_format_snd(@tcp_snd), file_path)
57
+ save(export_as_google_api_format_snd(@tcp_snd), file_path)
56
58
  end
57
59
 
58
60
  def store_tcp_rec(dumped_tcp_rec)
59
- @tcp_rec.push self.merge_current_time(transfer_tcp_rec_to_hash_rec(dumped_tcp_rec))
61
+ @tcp_rec.push merge_current_time(transfer_tcp_rec_to_hash_rec(dumped_tcp_rec))
60
62
  end
61
63
 
62
64
  def store_tcp_snd(dumped_tcp_snd)
63
- @tcp_snd.push self.merge_current_time(transfer_tcp_rec_to_hash_snd(dumped_tcp_snd))
65
+ @tcp_snd.push merge_current_time(transfer_tcp_rec_to_hash_snd(dumped_tcp_snd))
64
66
  end
65
67
 
66
68
  def transfer_tcp_rec_to_hash_rec(dumped_tcp_rec)
@@ -79,11 +81,10 @@ module Droid
79
81
  google_api_data_format = empty_google_api_format_rec
80
82
 
81
83
  from_tcp_rec.each do |hash|
82
-
83
84
  a_google_api_data_format = {
84
85
  c: [
85
86
  { v: hash[:time] },
86
- { v: hash[:tcp_rec] },
87
+ { v: hash[:tcp_rec] }
87
88
  ]
88
89
  }
89
90
  google_api_data_format[:rows].push(a_google_api_data_format)
@@ -96,11 +97,10 @@ module Droid
96
97
  google_api_data_format = empty_google_api_format_snd
97
98
 
98
99
  from_tcp_snd.each do |hash|
99
-
100
100
  a_google_api_data_format = {
101
101
  c: [
102
102
  { v: hash[:time] },
103
- { v: hash[:tcp_snd] },
103
+ { v: hash[:tcp_snd] }
104
104
  ]
105
105
  }
106
106
  google_api_data_format[:rows].push(a_google_api_data_format)
@@ -112,9 +112,9 @@ module Droid
112
112
  # @params [String] data_file_path A path to data.
113
113
  # @params [Hash] graph_opts A hash regarding graph settings.
114
114
  # @params [String] output_file_path A path you would like to export data.
115
- def create_graph(data_file_path, graph_opts = {}, output_file_path)
116
- self.save(Droid::Monitor::GoogleApiTemplate.create_graph(data_file_path, graph_opts),
117
- output_file_path)
115
+ def create_graph(data_file_path, graph_opts = {}, output_file_path) # rubocop:disable Style/OptionalArguments
116
+ save(Droid::Monitor::GoogleApiTemplate.create_graph(data_file_path, graph_opts),
117
+ output_file_path)
118
118
  end
119
119
 
120
120
  private
@@ -123,10 +123,9 @@ module Droid
123
123
  {
124
124
  cols: [
125
125
  { label: 'time', type: 'string' },
126
- { label: 'tcp_rec', type: 'number' },
127
- ],
128
- rows: [
126
+ { label: 'tcp_rec', type: 'number' }
129
127
  ],
128
+ rows: []
130
129
  }
131
130
  end
132
131
 
@@ -134,14 +133,11 @@ module Droid
134
133
  {
135
134
  cols: [
136
135
  { label: 'time', type: 'string' },
137
- { label: 'tcp_snd', type: 'number' },
138
- ],
139
- rows: [
136
+ { label: 'tcp_snd', type: 'number' }
140
137
  ],
138
+ rows: []
141
139
  }
142
140
  end
143
-
144
-
145
141
  end # class Cpu
146
142
  end # module Monitor
147
143
  end # module Droid