5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/jobs/better_rails_debugger/analysis_recorder_job.rb', line 5
def perform(recorded={})
recorded = recorded.symbolize_keys
if not recorded[:instance_id].present?
Rails.logger.error "[BetterRailsDebugger AnalysisRecorderJob] intance_id not found. Skiping..."
return
end
instance = GroupInstance.find recorded[:instance_id]
if not instance.present?
Rails.logger.error "[BetterRailsDebugger AnalysisRecorderJob] GroupInstance '#{recorded[:instance_id]}' not found. Skiping..."
return
end
instance.status = 'processing'
instance.save
allocations_per_file = Hash.new(0)
memsize_per_file = Hash.new(0)
instance.objects.all.each do |object|
allocations_per_file[object.source_file] += 1
memsize_per_file[object.source_file] += object.memsize
start = (l = object.source_line - 4) >= 0 ? l : 0
object.source_code = IO.readlines(object.source_file)[start..(object.source_line + 4)].join("\n")
object.save
end
instance.allocations_per_file = allocations_per_file.to_json
instance.memsize_per_file = memsize_per_file.to_json
instance.status = 'finished'
instance.save
end
|