Module: Xcprofiler
- Defined in:
- lib/xcprofiler.rb,
lib/xcprofiler/version.rb,
lib/xcprofiler/profiler.rb,
lib/xcprofiler/execution.rb,
lib/xcprofiler/exceptions.rb,
lib/xcprofiler/derived_data.rb,
lib/xcprofiler/reporters/json_reporter.rb,
lib/xcprofiler/reporters/block_reporter.rb,
lib/xcprofiler/reporters/abstract_reporter.rb,
lib/xcprofiler/reporters/standard_output_reporter.rb
Defined Under Namespace
Classes: AbstractReporter, BlockReporter, BuildFlagIsNotEnabled, DerivedData, DerivedDataNotFound, Execution, JSONReporter, OutputPathIsNotSpecified, Profiler, StandardOutputReporter
Constant Summary collapse
- VERSION =
"0.6.3"
Class Method Summary collapse
Class Method Details
.execute(args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/xcprofiler.rb', line 16 def execute(args) = OpenStruct.new .order = :time .reporters = [:standard_output] parser = OptionParser.new do |opts| opts. = "Usage: xcprofiler [product name or .xcactivitylog file] [options]".red opts.on("--[no-]show-invalids", "Show invalid location results") { |v| .show_invalid_locations = v } opts.on("-o [ORDER]", [:default, :time, :file], "Sort order") { |v| .order = v } opts.on("-l", "--limit [LIMIT]", Integer, "Limit for display") { |v| .limit = v } opts.on("--threshold [THRESHOLD]", Integer, "Threshold of time to display(ms)") { |v| .threshold = v } opts.on("--derived-data-path", String, "Root path of DerivedData") { |v| .derived_data_path = v } opts.on("-t", "--truncate-at [TRUNCATE_AT]", Integer, "Truncate the method name with specified length") { |v| .truncate_at = v } opts.on("--[no-]unique", "Reject duplicated location results or not") { |v| .unique = v } opts.on("--output [PATH]", String, "File path to output reporters' result") { |v| .output = v } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end parser.parse!(args) target = args.pop unless target puts parser exit 1 end order = [:order] or :time begin if target.end_with?('.xcactivitylog') profiler = Profiler.by_path(target) else derived_data_path = [:derived_data_path] profiler = Profiler.by_product_name(target, derived_data_path) end reporter_args = { limit: [:limit], threshold: [:threshold], order: order, show_invalid_locations: [:show_invalid_locations], truncate_at: [:truncate_at], unique: [:unique] } reporters = [StandardOutputReporter.new(reporter_args)] if [:output] json_args = .dup json_args[:output_path] = [:output] reporters << JSONReporter.new(json_args) end profiler.reporters = reporters profiler.report! rescue Exception => e puts e..red end end |