xcprofiler 0.5.0 → 0.6.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: 619014224d306a694c7da11d1ed1306b9b2e3fac
4
- data.tar.gz: c0b91191a1208dff867f74cde952515736439118
3
+ metadata.gz: 96174bfd64462a8f8a140c968cec38465568ece7
4
+ data.tar.gz: 5bc873480019dea46b48dba6e74633fc738d7e26
5
5
  SHA512:
6
- metadata.gz: 3239189c1c076857ca30a1d68a1682452118e963d2491750c08b4ddacf0a1a9dc61c5027e0c35910469e38b7a4ec4ce268b08ea05f3429bdfd80614b542b09ed
7
- data.tar.gz: ca139ec88be8f4d7f8429018b04df948e1eb961259c89733f16895cd6698fea69591c09f10aab7b64e8962812a51eba292bcbf8213f308443d97c22aa0172ee1
6
+ metadata.gz: 7907ec7bd31c2be0e522d8691e8258123f948325029f198e39d34e66aebaf43c279739c55f4a12e2dcd997f1b4fa016760ce36a9c4afd14203de98c260204a18
7
+ data.tar.gz: eeca6143e71a334f18acefe010cfd289d9675a505d7cfc3af6e21e23d0f4eaefeba094613e2fa5096a993682ffcfebef9690d65df5592c53bf2409bf8a22e32f
data/README.md CHANGED
@@ -76,6 +76,7 @@ Sample output is here
76
76
  |--order|-o|Sort order (default,time,file)|
77
77
  |--derived-data-path||Root path of DerivedData directory|
78
78
  |--truncate-at|-t|Truncate the method name with specified length|
79
+ |--no-unique|Show the duplicated results|
79
80
 
80
81
  ## Use custom reporters
81
82
 
@@ -86,8 +87,11 @@ require 'xcprofiler'
86
87
 
87
88
  profiler = Xcprofiler::Profiler.by_product_name('MyApp')
88
89
  profiler.reporters = [
89
- Xcprofiler::StandardOutputReporter.new(limit: 20, order: :time)],
90
- Xcprofiler::JSONReporter.new({output_path: 'result.json'})
90
+ Xcprofiler::StandardOutputReporter.new(limit: 20, order: :time),
91
+ Xcprofiler::JSONReporter.new(output_path: 'result.json'),
92
+ Xcprofiler::BlockReporter.new do |executions|
93
+ do_something(executions)
94
+ end,
91
95
  ]
92
96
  profiler.report!
93
97
  ```
@@ -4,6 +4,7 @@ require "xcprofiler/execution"
4
4
  require "xcprofiler/profiler"
5
5
  require "xcprofiler/version"
6
6
  require "xcprofiler/reporters/abstract_reporter"
7
+ require "xcprofiler/reporters/block_reporter"
7
8
  require "xcprofiler/reporters/standard_output_reporter"
8
9
  require "xcprofiler/reporters/json_reporter"
9
10
  require "colorize"
@@ -26,6 +27,7 @@ module Xcprofiler
26
27
  opts.on("--threshold [THRESHOLD]", Integer, "Threshold of time to display(ms)") { |v| options.threshold = v }
27
28
  opts.on("--derived-data-path", String, "Root path of DerivedData") { |v| options.derived_data_path = v }
28
29
  opts.on("-t", "--truncate-at [TRUNCATE_AT]", Integer, "Truncate the method name with specified length") { |v| options.truncate_at = v }
30
+ opts.on("--[no-]unique", "Reject duplicated location results or not") { |v| options.unique = v }
29
31
  opts.on_tail("-h", "--help", "Show this message") do
30
32
  puts opts
31
33
  exit
@@ -48,13 +50,12 @@ module Xcprofiler
48
50
  derived_data_path = options[:derived_data_path]
49
51
  profiler = Profiler.by_product_name(target, derived_data_path)
50
52
  end
51
- profiler.reporters = [
52
- StandardOutputReporter.new(limit: options[:limit],
53
+ profiler.reporters = [StandardOutputReporter.new(limit: options[:limit],
53
54
  threshold: options[:threshold],
54
55
  order: order,
55
56
  show_invalid_locations: options[:show_invalid_locations],
56
- truncate_at: options[:truncate_at])
57
- ]
57
+ truncate_at: options[:truncate_at],
58
+ unique: options[:unique])]
58
59
  profiler.report!
59
60
  rescue Exception => e
60
61
  puts e.message.red
@@ -1,14 +1,14 @@
1
1
  module Xcprofiler
2
2
  class Execution
3
- Struct.new('Position', :path, :line, :column)
3
+ Struct.new('Location', :path, :line, :column)
4
4
 
5
- attr_reader :time, :position, :method_name
5
+ attr_reader :time, :location, :method_name
6
6
 
7
- def initialize(time, position, method_name)
7
+ def initialize(time, location, method_name)
8
8
  @time = time.to_f
9
- unless position =~ /<invalid loc>/
10
- path, line, column = position.split(':')
11
- @position = Struct::Position.new(path, line.to_i, column.to_i)
9
+ unless location =~ /<invalid loc>/
10
+ path, line, column = location.split(':')
11
+ @location = Struct::Location.new(path, line.to_i, column.to_i)
12
12
  end
13
13
  @method_name = method_name
14
14
  end
@@ -24,12 +24,12 @@ module Xcprofiler
24
24
  end
25
25
 
26
26
  def invalid?
27
- !position
27
+ !location
28
28
  end
29
29
 
30
30
  def path
31
- if @position
32
- @position.path
31
+ if @location
32
+ @location.path
33
33
  else
34
34
  nil
35
35
  end
@@ -44,16 +44,16 @@ module Xcprofiler
44
44
  end
45
45
 
46
46
  def column
47
- if @position
48
- @position.column
47
+ if @location
48
+ @location.column
49
49
  else
50
50
  nil
51
51
  end
52
52
  end
53
53
 
54
54
  def line
55
- if @position
56
- @position.line
55
+ if @location
56
+ @location.line
57
57
  else
58
58
  nil
59
59
  end
@@ -21,7 +21,7 @@ module Xcprofiler
21
21
  end
22
22
 
23
23
  def report!
24
- if !derived_data.flag_enabled?
24
+ unless derived_data.flag_enabled?
25
25
  raise BuildFlagIsNotEnabled, "'-Xfrontend -debug-time-function-bodies' flag is not enabled"
26
26
  end
27
27
 
@@ -13,9 +13,10 @@ module Xcprofiler
13
13
  end
14
14
 
15
15
  def filter_executions(executions)
16
- executions = sort_executions(executions, order)
17
16
  executions = executions.delete_if(&:invalid?) unless show_invalid_locations?
17
+ executions = delete_duplicated(executions) if unique
18
18
  executions = executions.delete_if { |v| v.time < threshold } if threshold
19
+ executions = sort_executions(executions, order)
19
20
  executions = executions[0...limit] if limit
20
21
  executions
21
22
  end
@@ -33,6 +34,14 @@ module Xcprofiler
33
34
  end
34
35
  end
35
36
 
37
+ def delete_duplicated(executions)
38
+ executions.group_by { |execution|
39
+ execution.location
40
+ }.map { |location, executions|
41
+ executions.max { |execution| execution.time }
42
+ }
43
+ end
44
+
36
45
  def limit
37
46
  options[:limit]
38
47
  end
@@ -52,5 +61,10 @@ module Xcprofiler
52
61
  def truncate_at
53
62
  options[:truncate_at] ||= DEFAULT_TRUNCATE_AT
54
63
  end
64
+
65
+ def unique
66
+ return options[:unique] unless options[:unique].nil?
67
+ true
68
+ end
55
69
  end
56
70
  end
@@ -0,0 +1,13 @@
1
+ module Xcprofiler
2
+ class BlockReporter < AbstractReporter
3
+ def initialize(options = {}, &block)
4
+ raise ArgumentError, '[BlockReporter] block must be passed' unless block_given?
5
+ super(options)
6
+ @block = block
7
+ end
8
+
9
+ def report!(executions)
10
+ @block.call(executions)
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Xcprofiler
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcprofiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - giginet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,7 @@ files:
120
120
  - lib/xcprofiler/execution.rb
121
121
  - lib/xcprofiler/profiler.rb
122
122
  - lib/xcprofiler/reporters/abstract_reporter.rb
123
+ - lib/xcprofiler/reporters/block_reporter.rb
123
124
  - lib/xcprofiler/reporters/json_reporter.rb
124
125
  - lib/xcprofiler/reporters/standard_output_reporter.rb
125
126
  - lib/xcprofiler/version.rb
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  version: '0'
144
145
  requirements: []
145
146
  rubyforge_project:
146
- rubygems_version: 2.5.1
147
+ rubygems_version: 2.6.8
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: CLI to profile compilation time of Swift projects