class XCActivityLog::IDEActivityLogSection
Constants
- TargetInfo
Public Instance Methods
duration_usec()
click to toggle source
# File lib/xcactivitylog/objects.rb, line 106 def duration_usec time_stopped_recording_usec - time_started_recording_usec end
each() { |self| ... }
click to toggle source
# File lib/xcactivitylog/objects.rb, line 92 def each(&blk) return enum_for(__method__) unless block_given? yield self subsections&.each { |s| s.each(&blk) } end
each_trace_event() { |section: section, parent: parent, thread_id: thread_id| ... }
click to toggle source
# File lib/xcactivitylog/objects.rb, line 116 def each_trace_event thread_id_map_by_section_type = Hash.new { |h, k| h[k] = [] } each_with_parent.sort_by { |s, _| s.time_started_recording }.each do |section, parent| thread_id_map = thread_id_map_by_section_type[section.section_type] best_thread, thread_id = thread_id_map.each_with_index.select do |thread, _tid| section.time_started_recording > thread.last.time_stopped_recording end.min_by do |thread, _tid| (section.time_started_recording - thread.last.time_stopped_recording) + (thread.last.time_stopped_recording - thread_id_map.map(&:last).map(&:time_stopped_recording).min) end unless thread_id thread_id = thread_id_map.size best_thread = [] thread_id_map << best_thread end best_thread << section yield(section: section, parent: parent, thread_id: thread_id) end end
each_with_parent(parent: nil) { |self, parent| ... }
click to toggle source
# File lib/xcactivitylog/objects.rb, line 99 def each_with_parent(parent: nil, &blk) return enum_for(__method__) unless block_given? yield self, parent subsections&.each { |s| s.each_with_parent(parent: self, &blk) } end
severity()
click to toggle source
# File lib/xcactivitylog/objects.rb, line 170 def severity severity = (messages || []).reduce(Severity::SUCCESS) { |a, e| [a, Severity.new(e.severity)].max } (subsections || []).reduce(severity) { |a, e| [a, e.severity].max } end
target_info(parent: nil)
click to toggle source
# File lib/xcactivitylog/objects.rb, line 110 def target_info(parent: nil) parent&.target_info || (title =~ /=== BUILD TARGET (.+?) OF PROJECT (.+?) WITH CONFIGURATION (.+?) ===/ && TargetInfo.new(name: Regexp.last_match(1), configuration: Regexp.last_match(3), workspace: Regexp.last_match(2))) end
write_chrome_trace_file(section_type:, to:)
click to toggle source
# File lib/xcactivitylog/objects.rb, line 137 def write_chrome_trace_file(section_type:, to:) to << '{"traceEvents":[' << "\n" written_comma = false each_trace_event do |section:, parent:, thread_id:| case section.section_type when section_type if written_comma to << ",\n" else written_comma = true end require 'json' to << JSON.generate( pid: section.section_type.to_s, tid: thread_id, ts: section.time_started_recording_usec, ph: 'X', name: section.title.dup&.force_encoding('UTF-8'), dur: section.duration_usec, args: { subtitle: section.subtitle.dup&.force_encoding('UTF-8'), target: section.target_info(parent: parent).to_h, severity: section.severity } ) end end to << "\n]}" to end